History: Template Overview
Source of version: 7
Copy to clipboard
''(from [http://doc.tikiwiki.org/tiki-index.php?page=Styles+and+Themes|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 [http://smarty.php.net/|smarty.php.net]. You can modify just the html in .tpl files though, and comment out some of the logic for features you never use. Be careful to keep backups though because a smarty error in a main template is a good way to crash your site. !!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-top_bar.tpl'': site Look & Feel options and/or menu ** ''tiki-site_header.tpl'': site Look & Feel options ** ''tiki-bot_bar.tpl'': bottom banner links/credits bar (Whether ''tiki-top_bar.tpl'' or ''tiki-site_header.tpl'' or both needs to be modified depends on what theme files are used as a starting point for a custom theme. ((Themes_for_TW2|New themes)) tend to use ''tiki-site_header.tpl'' for more Look & Feel components, and reserve ''tiki-top_bar.tpl'' for the menu (usually PHP Layers) and sometimes the search form.) (As of TikiWiki 2, there is no need to edit the error.tpl file (which formerly was identical to tiki.tpl except for having error-specific main content). Template files with names like ''tiki-print.tpl'' usually don't need to be changed. The layout of the whole Tiki page can be changed by modifying just one file or a few files. __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 is necessary to edit template files to make major rearrangements of items on the page. One example is to change the normal three-column layout to two or one columns, or to add a module to the top bar. !!Wiki Templates (More Advanced) * tiki-showpage.tpl - main wiki template, upper controls * tiki-page_bar.tpl - lower controls Unless there is a special need to emulate an existing theme, generally speaking, the best course is probably to base new theme templates on the default Tiki templates, that is, on templates/tiki.tpl, templates/tiki-top_bar.tpl, and so on. However, TikiWiki release 2 is in a transition period and the bundled themes include older ones that use an old-school table-based layout method, and new themes that use the *litecss table-free layout method. Choose as a model (and use the files of) whichever is closest to the target design (also see ((Themes_for_TW2)) ). !!! 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 synch with the functionality of Tiki as it advances.