[Show/Hide Left Column]
[Show/Hide Right Column]

Template basics
Print

Template Overview

(from Style and Themes - to be updated)

How to modify .tpl files

About Smarty
The .tpl (template) files are written using the Smarty template language, which has its own syntax, etc. Smarty is mainly used for defining environment variables and the logic that follows (like who to show what when how). See smarty.php.net (cache).

Modifying the .tpl files isn't recommended if the site's appearance can be changed using CSS alone; sometimes it is necessary, though, but be sure to be familiar with Smarty syntax and how Tiki uses Smarty files before going this route.

The Template Tree

Tiki's templates are called in a specific order within the code, so it's good to know what is a parent of what, particularly for the main few used for the basic layout of the site.

Templates (most frequently modified)

  • tiki.tpl: the main template defining the layout, which calls:
    • header.tpl: the HTML head section (avoid modifying, if possible)
    • tiki-site_header.tpl: site Look & Feel options and/or menu
    • tiki-top_bar.tpl: possibly menu and search form
    • tiki-bot_bar.tpl: bottom banner links/credits bar

(Whether tiki-site_header.tpl or tiki-top_bar.tpl or both needs to be modified depends on what theme files are used as a starting point for a custom theme. New themes tend to use tiki-site_header.tpl for more Look & Feel components, and reserve tiki-top_bar.tpl for the menu (usually a CSS, or suckerfish, menu) and sometimes the search form.)

The new power of L&F custom code

In Tiki 4 and Tiki 5, a number of custom code text areas have been added on the Look and Feel admin page that may make it unnecessary to modify the relevant .tpl file, depending on what the desired customization is. This course should be considered first as it's easier to update the site to new Tiki versions when there are fewer file customizations.

Smarty template start/end tags

To put Smarty template beginning and end tags in comments in the final page source, as of Tiki 4 there is an option in Admin Features(tiki-admin.php?page=features), under the Developer tab, called "Smarty Template usage indicator". As indicated on that page, "Use only for development, not in production because these warnings are added to emails as well, and visible to the users." You can then check the final page source to see what code is produced by what Smarty template file.

Theme-Specific Templates

To modify the layout of Tiki in your theme, edit theme-specific copies of default Tiki template files. While CSS editing is used to specify the details of page appearance, it may be necessary to edit template files to make major rearrangements of items on the page. But an increasing amount of flexibility is being added to Tiki via admin configuration, which tends to make template editing unnecessary.

Overriding templates

The template files for each theme are stored in a directory with the same name as the theme (less the ".css" file type indicator) in the templates/styles directory — for example, templates/styles/screensite.

A theme's files will override any default template file. You just need to put a modified template file in the directory templates/styles/custom_theme_name.

For example, if we want to modify the forum listing in our screensite theme, we'd just place a copy of the file templates/tiki-forums.tpl in templates/styles/screensite/ and then edit the new theme-specific copy of the tiki-forums.tpl file.

Tiki will substitute whatever is in your custom theme directory for the .tpl files in the default directory.

This technique works on files in the subdirectories, too. That is, to change the application menu in your theme, just copy the file mod-application_menu.tpl from templates/modules/ to templates/styles/custom_theme_name/modules/.

It's recommended that as few template files be customized as possible, and the customizations kept as minimal as possible, in order to keep the maintenance and updating of the files easier. The more extensive the customization, the harder to keep in sync with the functionality of Tiki as it advances.


Theme: Fivealive [toggle]

Shoutbox

chibaguy, 01:00 GMT, Thu 02 of Sep., 2010: By the way, object-level theme control isn't working with regard to tpl files, so use user pref or switch-theme module for best view of themes (esp. those with custom tpl files).
chibaguy, 00:55 GMT, Thu 02 of Sep., 2010: Sorry, orionrobots, I didn't update Planetfall for Tiki 5 yet, and this site still has the T4 version. Still, I think there isn't much to update. Did you try Planetfall at this site using the switch-theme module?
orionrobots, 18:49 GMT, Wed 01 of Sep., 2010: Hmm - looks like planetfall is not quite right on Themes.tw.o - I am having a hard time with it on a TW5 upgrade on the Orionrobots test site too.
chibaguy, 01:13 GMT, Thu 05 of Aug., 2010: tochinet, sounds like the wrong (or too many) template files are being used. Can you post in the forum and give more details? (Also Tikipedia hasn't been updated for a while, so indicate what Tiki version, etc.)
tochinet, 06:55 GMT, Wed 04 of Aug., 2010: Can someone look at the Tikipedia theme ? On my Firefox, the logo appears twice, there are two lines of links a bit hidden the logo, etc. Maybe it is something simple, I don't know.

Show php error messages