Introduction to position variations
SEBLOD comes pre-loaded with some position variations which can be a useful way to add styling directly to your template positions. As a demonstration, select the seb_CSS3 variation and then click the "+". In the popup window, you have the option to add many of your own styling parameters directly to your template position. This is a quick way to add some simple styling, without needing to write any code!
Alternatively, you can create your own position variation which will appear in this list. Creating a position variation can be useful, as it gives you a re-usable layout that you can use on different Content Types and List & Search Types.
Position variations for your selected template are available at the top of the each position in your template (see right).
Position variations for your selected template are available at the top of the each position in your template (see right).
Creating a position variation
Variations
are simple to make, that's the beauty of them. Let's take a very simple scenario: I want to
have a variation that takes the content of a position, wraps it in a
and places a Google Adsense add immediately after that position. I
will start by naming my file my_adsense.php and I will place it in the
variations folder, within another folder with the
exact same name as my .php file. For example: seb_one/variations/my_adsense/ directory. I then open that file and place the
following code in it:
<?php // No Direct Access defined( '_JEXEC' ) or die; ?> <div> <?php echo $content; ?> <!-- AdSense Javascript Here --> </div>
It's that simple. $content is a variable available within all variation
files, and what it does is return all rendered fields in the position
on which you applied this variation to. In our case we simply wrapped
all that content in a div, added our AdSense code, but you can replace that code with whatever you want.
You can also render a single field, or a selection of fields in the position by using the standard SEBLOD template API to retrieve your fields ( See the Retrieving Your Fields section of the Overriding a Position Manual):
You can also render a single field, or a selection of fields in the position by using the standard SEBLOD template API to retrieve your fields ( See the Retrieving Your Fields section of the Overriding a Position Manual):
<?php // No Direct Access defined( '_JEXEC' ) or die; ?> <div> <?php echo $cck->renderField('field_name'); ?> <!-- AdSense Javascript Here --> </div>
Where
field_name is the name of the field you wish to render. You can of
course render any field(s) you have assigned to the position you're
applying this variation to.