In tiki, each PHP script that can be invoked through the browser has a corresponding .TPL (Smarty) file. These files can often become quite long and complex. In some cases, a same TPL file will be used to carry out operations which are quite different and require quite different visual elements.

For example, consider the case of tiki-editpage.tpl. This is used for:

  • Editing the content of an existing page
  • Editing the content of a new page
  • Asking the user for the language of a page that he wants to create
  • Update a page in one language, based on changes that have been made in another language


Instead of having one big monolithic TPL file, it can make sense to split it into smaller chunks.

You can do this using the Smarty include statements.

For example you could have tiki-editpage.tpl be something like this:

Copy to clipboard
{if $need_lang == 'y'} {include file=tiki-editpage-ask_for_language.tpl} {elsif $updateTranslation == 'y'} {include file=tiki-editpage-update_translation.tpl} {else} {include file=tiki-editpage-edit_existing.tpl} {/if}


Where each of the three TPL file has the Smarty code for one of the specific dialogs.

Note that these dialogs themselves can include TPL files. For example, the tiki-editpage-update_translation.tpl and tiki-editpage-edit_existing.tpl dialogs may need to use a common TPL, because both need a widget for editing the content of a an existing page. So, they themselves may include a common template, call it tiki-editpage-page_editor.tpl.

Related topics: Code Howto: Writing re-usable Smarty widgets