Templates

Tribiq CMS uses a templating system to deliver content to visitor-facing pages. This ensures consistency across sections of a site.

What are Templates?

Template Files are held in the file system, and thus require file system access to modify them. Template Files contain snippets of PHP to define Slots, which are the "hooks" for putting Plugins onto a page (all content comes from one Plugin or another). To render a page, Tribiq CMS merges the output of all of a page's Plugins into a Template File, and then your browser displays it with a Skin (the CSS and images of a page design).

Templates - as opposed to Template Files - are virtual. They are instances of a Template File, and consist of a Template File, a set of given Plugins configured to appear in given Slots, and a given Skin.

Template Files are arranged into Families, the Family being the equivalent of the directory  containing one or more Template Files. Most Tribiq CMS sites have just one Family.

Where are my Template Files?

FinderScreenSnapz004.jpgIn your Tribiq CMS directory, you will find a folder called my_tribiq_templates.

Inside that folder you will find one folder for each Template Family. In this example the only Family is general_purpose.

Inside that folder you will find Template Files, they have names like 2-col.tpl.php and 3-col.tpl.php. There is also a folder called includes, and that contains sections of template files that are repeatedly included.

What does a Slot look like?

Templates need to contain Slots for Plugins. Let's take a look what the simplest possible Slot could look like.

A simple Slot could be defined like this:

<?php if ($slot = slot('Main_1_1')) { ?>
    <div class="slot Main_1_1">
<?php $slot->show(); ?>
</div>
<?php $slot->end(); } ?>

The first line defines the start of Slot called Main_1_1; and the last line defines the end of the Slot.

The second and fourth line define the <div>; the CSS (in the Skin) will hang off this. By having the CSS class name slot in the the div, the CSS can target the Slot to make it display with a border.

The third line is PHP again, that tells the CMS to merge the output of the Plugin that's in Slot Main_1_1 at this location in the output.

Adding more style to Slots

In practice, Slots contain a little more code than the simple example above. Here is the same Slot, in the form which you will find in the Template Files that ship with Tribiq CMS:

<?php if ($slot = slot('Main_1_1')) { ?>
    <div class="slot Main_1_1">
        <div class="border borderUpperLeft"></div>
        <div class="border borderUpperCenter"></div>
        <div class="border borderUpperRight"></div>
        <div class="border borderLeft"></div>
        <div class="center">
            <?php $slot->show(); ?>
        </div>
        <div class="border borderRight"></div>
        <div class="border borderLowerLeft"></div>
        <div class="border borderLowerCenter"></div>
        <div class="border borderLowerRight"></div>
    </div>
<?php $slot->end(); } ?>

The extra <div> tags are there so that designers can create more attractive styles around each Slot, such as rounded corners, whch would not be possible with just a single <div>.

Do I need to make new Templates?

Probably not! The two Template Files 2-col.tpl.php (which works for 1 and 2 column pages) and 3-col.tpl.php are highly versatile, and you can achieve most web page designs using these files. 

Remember that all styling information is held in Skins. So you should use Skins to define the design of your site.

However, if the Template Files don't have enough Slots, or if the nesting of the <div> tags does not work for your design, then you may need to make new Template Files.

You can add a comment here