Important

Major updates are in progress. Some pages and languages may not be available.

Modifying Templates

Tiki uses Smarty (TPL) template files to control the presentation (that is, the display) of each page of your Tiki website. The Smarty template engine allows you to separate the presentation (look & feel) from the logic (programming).

 Tip

New to Tiki? See "Editing Templates" in Tiki for Dummies Smarties for basic information.

 Note

Do not confuse these Smarty (TPL) template files with the Tiki content templates.

 Tip

For complete information on using Smarty, see http://www.smarty.net/.

Any template files that you modify should be placed in a custom theme folder — do not modify the template files in the ../templates/*.tpl folder. See Saving Your Theme for more information.

 Note

Creating modified template files as part of your custom theme may make it more difficult to upgrade your Tiki. You will need to re-apply your customizations to the new set of templates each time you upgrade.


Finding the Right Template

So, how do you figure out which of the more than 800 template (TPL) files you need to edit? Some template files have a direct, one-to-one correlation with a PHP file. This means you simply need to look a the browser's address bar to determine the correct template.
{TIP()}The Template Map provides a detailed listing of which templates include others.{TIP}

For example, the template used for the site registration page (tiki-register.php) is tiki-register.tpl.

PHP and TPL file
One template per page.


For other pages it is not nearly that easy. Some pages, such as the event calendar (tiki-calendar.php) are actually made up of five (or more!) different templates. Luckily, there is an option to help you find which templates are used.


When you enable the Smarty template usage indicator option on the Miscellaneous tab of the Admin: Look & Feel page, Tiki will add comments to the generated HTML files that identify the beginning and ending of each template (TPL) file.

Admin: Look and Feel page
Enabling the template indicator.


When you enable the Smarty template usage indicator option on the Miscellaneous tab of the Admin: Look & Feel page, Tiki will add comments to the generated HTML files that identify the beginning and ending of each template (TPL) file.

Admin: Look and Feel page
Enabling the template indicator.


When you enable the Smarty template usage indicator option on the Miscellaneous tab of the Admin: Look & Feel page, Tiki will add comments to the generated HTML files that identify the beginning and ending of each template (TPL) file.

Admin: Look and Feel page
Enabling the template indicator.


When you enable the Smarty template usage indicator option on the Theme tab of the Admin: Look & Feel page, Tiki will add comments to the generated HTML files that identify the beginning and ending of each template (TPL) file.

Admin: Look and Feel page
Enabling the template indicator.


By viewing the HTML source of a generated Tiki page, you can determine which template (TPL) is responsible for what content, as shown below:

HTML source
Enabling the template indicator

 Warning

Do not use the Smarty Template usage indicator on a "live" site. Tiki will include the template comments in all generated content, including messages and email, and these comments will be visible to all site users.

Including Wiki Syntax

The Tiki template (TPL) files are created with the Smarty template engine. Smarty templates use a mixture of XHTML and PHP — not Tiki's wiki syntax. For example, to bold text in a Smarty TPL template file, use:

<strong>text</strong>


not:

__text__


However, there may be places that you need to use some wiki syntax. For example, you may want to include a wiki heading in template, use:

{wiki}
!Level 1 Heading
...
{/wiki}


Using modules and plugins

To include a Tiki module or plugin in a Smarty template (TPL) file, you must use the {literal} tag, in addition to the {wiki} tag, as shown previously.

For example, if you wanted to include the Tiki search module at the bottom of every web page on your Tiki site, you could add the following to the footer.tpl template:

Adding the Search module to a template
{wiki}
 {literal}
  {MODULE(module=>search, show_object_filter=y, advanced_search=y) /}
 {/literal}
{/wiki}

 Tip

You could also use the simplified version of the module:

{module module=search show_object_filter=y advanced_search=y}


See Using Modules for additional information about Tiki modules.

When adding plugins, you can use the {wikiplugin} tag to avoid having to use the {wiki} and {literal} tags:

Adding a wiki plugin to a template
{wikiplugin _name="NAME OF PLUGIN" PARAMETER="VALUE" PARAMETER="VALUE"}{/wikiplugin}

Advertising