![]()
Tribiq CMS relies on a system of Templates to deliver content to a visitor-facing page.
Templates are held in the file system. They cannot be modified, except by a designer with the requisite filesystem access.
Every Content Item of a Tribiq CMS site needs a Template to be specified, and also a Skin. Without these, it cannot be displayed properly.
Templates are usually arranged into Families.
Templates of the same Family usually have a similar overall layout. For example, one Family may be designed to present a page layout with 2 columns, while a different Family may be designed to present a layout with 3 columns.
A Family may have a name like tribiq-GPL-500. The first part is the author's name, the second part is the license (GPL is GNU Public License, while CL is Commercial License), and the third part is a serial number.
If you create your own Templates, we recommend you keep to this notation, although it is not essential.
Each Content Type in Tribiq CMS must use a different Template.
For example, all Document Content Items might use a Template called DOCU-standard.tpl.php. The first part of the name is the Content Type Prefix, and the second part is a general description.
Some sites have two or more Templates for HTML content. For example, if a home page needs to have a different layout from other web pages, you may have templates called HTML-home.tpl.php and HTML-standard.tpl.php.
The extension .tpl.php is essential for a Template to work correctly.
Templates are located inside your Tribiq CMS directory, in a sub-folder beneath the folder called templates.
In a Single Site configuration, the sub-folder is called mytribiqsite.
In a Multisite configuration, the sub-folder will be the Sitename of the site in question.
Beneath that sub-folder is the folder with the Template Family, and the Templates themselves are inside that.
So for example, underneath an installation may be a number of sub-folders like this:
templates/mytribiqsite/tribiq-GPL-500
Beneath that directory may be a number of Template files like this:
DOCU-standard.tpl.php
error.php
HTML-standard.tpl.php
NEWS-standard.tpl.php
PICT-standard.tpl.php
skins (a sub-folder)
In this example, all of the files ending in .tpl.php are Templates.
There is a special file called error.php which handles cases of 404 Not Found errors, and Authentication Failures. (See the Error Template section for more on this).
There is one sub-folder called skins folder, which holds the Skins determining the appearance of the page.
We highly recommend that you create a second sub-folder with a name such as includes, to place any code common to your Templates in. For example, most Templates in a Template Family share the same header and footer; this is implemented by having a header and a footer file in an includes sub-folder and including them in each Template using the lines
<?php include 'templates/'. TEMPLATE_PATH. '/includes/header.inc.php'; ?>
and
<?php include 'templates/'. TEMPLATE_PATH. '/includes/footer.inc.php'; ?>
Template files should contain HTML code to determine the basic layout of a page.
They may not contain any inline style information, as styles will be added by the Skins. They should, however, contain <div> tags with sensibly named CSS class names for the Skins to style.
Templates also need to contain Slots for Plugins. A typical slot looks something like this:
<?php if ($slot = slot('Main Slot 1')) { ?>
<div class="slot mainSlot mainSlot1">
<?php $slot->show(); ?>
</div>
<?php $slot->end(); } ?>
There are three lines of PHP code that need to be included, in order:
<?php if ($slot = slot('Main Slot 1')) { ?>
This line tells the CMS that a slot named "Main Slot 1" starts here. Note that you must ensure each slot on the page has a unique name.
<?php $slot->show(); ?>
This line marks the point in which the CMS will actually place the Plugin into the Slot.
<?php $slot->end(); } ?>
This marks the end of the slot.
Any HTML code you add inside the Slot will only be shown if the Slot is filled with a Plugin. You should take advantage of this to add elements that will only appear if the slot is used.
At the bare-minimum, you should add a <div> around the Slot with a CSS class-name of slot so that a Skin can give the Slot a border.
However, you may wish to add more <div> tags so that there is enough detail here to specify the precise styling information for the corners of each DIV, thus allowing a Skin to do nice things like rounded corners (instead of plain rectangular boxes). An example of this might be:
<?php if ($slot = slot('Main Slot 1')) { ?>
<div class="slot mainSlot mainSlot1">
<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(); } ?>
Such a section of code would typically be repeated several times throughout a Template.
You are advised to have a look at the Template files in the Community download (templates/mytribiqsite folder) to become familiar with Template files.
Remember that all styling information is held in Skins. A small number of Templates, designed in the above way, gives enough flexibility to build a large number of websites.
So, before embarking on building a new Template or Family, you should check whether an existing Template Family can do the job.
Your Templates should contain no PHP code other than the snippets mentioned above. If you want to write bespoke functionality, you should write a Plugin and insert it into a Slot in your Template.
You can add a comment here