Smarty Templates | |
Tiki uses the Smarty Template Engine to control themes (mostly the layout, and some design / layout logic).
http://www.smarty.net/whyuse.php Smarty is a "Template/Presentation Framework." It provides the designer with the opportunity to change the presentation of a website by defining variables and using logic (If/else) statements. It can be used for example to create WYSIWYCA ("what you see is what you can access") websites which show or hide things depending on permissions variables.
|
Default Templates and Custom Templates | |
The default Smarty template files are in the folder /Templates as .tpl files. They can be edited with any text editor, but it is best to not edit the default version of these templates. Since Tiki 15, if you want to modify a template, copy it and put the copy in the custom theme directory, e.g. themes /custom_theme_name/templates (it was /templates/styles/custom_theme_name/ prior to Tiki 15).
See Themes ("How To Create a Custom Theme") for more details.
|
Escaping variables used in Smarty | |
When modifying templates, it is important to check that variables that display output on screen be escaped except in certain circumstances, to act as a safeguard agains unfiltered user input being displayed back on the page. The question is when to escape and when not to escape? See http://www.smarty.net/docs/en/language.modifier.escape.tpl
|
Tips | |
|
Samples | |
Wikiplugin group | |
The wiki plugin group can be used the same way if you need to set it without an alternative to the condition ({else}) {wikiplugin _name='group' groups='Admins'} I’m a member of the admins group {/wikiplugin} However using {ELSE} like you would in the wiki syntax will break the code.
{if 'Admins'|in_group} I’m a member of the admins group {else} I’m not a member of the admins group {/if}
|
Using smarty modifier (number format) with data from a pluginList | |
You can't use directly the modifier |number_formatin a smarty template on a formatted field from a pluginList. IE: {$row.prix|number_format}You need to use it on the direct value from the tracker : {$row.tracker_field_catalogueDesBiensPRIX|number_format}
|
Use an URL parameter assigned to a smarty variable | |
With {$smarty.get.urlParameter} is possible to use an URL parameter directly into your smarty template.
that will generate https://yourTiki.com/holidays-camps-childrenList?holidayReference=Christmas In your smarty template you can reuse then the value to display it or embed a second wikiplugin list {filter field="tracker_field_holidaycampsNameReference" exact="{/literal}{$smarty.get.holiday}{literal}"}
Using the Tiki language preferencesYou can use the selected language to control what is displayed or used in embedded wikiplugin (like an embedded wikiplugin List) Using the language preferences {if $prefs.language eq fr}Montre ca {else} Show this {/if}
|
See also | |
|
More information | |
|
Alias | |