Template Tricks




Below, we will document some little template Tips. Typically show content depending on something. Can be done directly in templates/*.tpl files or in Admin > Look & Feel.

Custom CSS and JS

Starting in Tiki5, in Admin > Look & Feel (tiki-admin.php?page=look) > Miscellaneous, there is a Custom Code section to add custom CSS and JavaScript.

You can create styles/custom.js or styles/yourtheme/custom.js and that should get included automatically. You may need to empty your Tiki cache.

Change size of subtitle

custom CSS
#sitesubtitle {
font-size: 24px;

Help - I broke my theme

Apparently, a problem with my custom theme is preventing me from accessing my site normally.

Reset the theme "manually": If you can't access the admin pages to set your site's theme back to one that is known to work, you can reset the theme from the back end, so to speak.

Database method: Use phpMyAdmin on your server to access your Tiki database. In the table "tiki_preferences", find the row for "site_style". Edit this row by replacing the custom theme name with a standard theme, such as thenews.css.

FTP method (easier): Using your FTP client, go to the styles directory of your Tiki installation and rename the theme currently set as the site theme, such as by changing its ".css" file extension to ".txt". Tiki will revert to the default. Log in using the default theme and fix what is wrong. Also clear the site caches.

When trying out a new theme, it is much better to use the "switch theme" module to select it. Don't make a new and untried theme the site theme without first trying it out from the switch-theme module.

I am stuck in a theme

To change themes, you can point your browser to a non faulty theme:

  1. Point your browser to: tiki-switch_theme.php?theme=fivealive.css
  2. Then, also check to Clear the cache with tiki-admin_system.php?do=all

If anything doesn't change

For some unknown reason the theme doesn't change. Look directly in the database in 'tiki_preferences' look at:

  `value` =  'fivealive.css' 
  `tiki_preferences`.`name` =  'style';


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

  • If the output of your template will be used in another template as a variable that will be escaped there, then there is no need to escape it the first time as it will lead to double escaping.
  • If the variable is expected to possibly contain HTML, then it cannot be escaped otherwise the HTML will be displayed as text on screen. In those cases, it is the responsibility of the code that generated the HTML (e.g. the wiki parser to ensure that the HTML output is filtered), and the code of the input user interface to perform filtering in case any user enters any HTML - only trusted users should be allowed to enter any HTML).
  • If the variable is used for redisplaying what the user entered in an input text field, then it cannot be escaped otherwise it will lead to double escaping the next time the user submits the form.
  • In all other cases, the variable should be escaped using the escape variable.

Adding a print button only if current page is a wiki page

{if $page neq ''}	
 <a title="{tr}Print{/tr}" href="tiki-print.php?page={$page|escape:"url"}">
  <img src="https://themes.tiki.org/show_image.php?id=54"/>{tr}Print{/tr}

Adding some HTML (ex.: a logo) to the print version of wiki pages

Admin - Look and Feel - Customization - HTML
{if $SCRIPT_NAME eq '/tiki-print.php'}
<img src="http://themes.tiki.org/show_image.php?id=53" alt="Site Logo" style="border: none">

Page last modified on Thursday 03 of November, 2016 09:10:24 GMT

Switch Theme


Subscribe to Tiki Newsletters!

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other big news!
Contribute to Tiki

Site Config