Template Tricks
AboutBelow, 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 JSStarting 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 subtitlecustom CSS Copy to clipboard
Help - I broke my themeApparently, 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 themeTo change themes, you can point your browser to a non faulty theme:
If anything doesn't changeFor some unknown reason the theme doesn't change. Look directly in the database in Copy to clipboard
Howto
Escaping variables used in SmartyWhen 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
Adding a print button only if current page is a wiki pageCopy to clipboard
Adding some HTML (ex.: a logo) to the print version of wiki pagesAdmin - Look and Feel - Customization - HTML Copy to clipboard
Adding a "Hello John" indicationCopy to clipboard
Adding content only for a groupIn content
In a template
Copy to clipboard
Adding content only for a permissionCopy to clipboard
Adding content only for a preferenceCopy to clipboard
Dislay the value of a Tiki preference in contenthttps://doc.tiki.org/PluginSmarty#Display_a_Tiki_preference_in_content_such_as_a_wiki_page Adding content only for a category
Copy to clipboard
Display content conditional to current languageCopy to clipboard
Example:
If the current language is en, Hello will be displayed. If it is pt-br, Olá. To make users switch language, you can add Module switch_lang or hard code some links such as: Copy to clipboard
How to know where something is in a template?Admin > Look & Feel > Add HTML comment at start and end of each Smarty template (TPL). Then, clear your template cache (tiki-admin_system.php?do=templates_c) The system name for this feature is "log_tpl". Then, when you "view source" with your browser, you will see which template was used to create it. Make sure to turn off once you go into production, or else your email notifications will also have a note! How do I know which template to modify to affect the look & feel of a specific URL?Generally, if the page name is tiki-abc.php, look templates/tiki-abc.tpl If you can't find it:
How do I change the email messages?Look in: templates/mail/ Ex.: templates/mail/share_subject.tpl contains Copy to clipboard
How to show content just when in certain pages/features. Ex.: tiki-searchresults.phpSo if you want to modify tiki-searchresults.php, you find templates/tiki-searchresults.tpl For the containertemplates/tiki.tpl is the master container. Say you want to affect the master container based on the current page, you can do Copy to clipboard
Add a Banner for each Blog, like a personal logo headeradd the following code in Site Ads and Banners Content:in Site Ads and Banners section in Administration menu. http://www.yoursite.com/tiki-admin.php?page=ads
Copy to clipboard
How to force switch Theme for AnonymousYou could use the Group Theme feature but it seems broken currently in Tiki 5 so here's a workaround using JavaScript code in Admin > Look & Feel > General Layout > Custom HTML <head> Content ("Registered users can switch themes" - preference name change_theme - must be enabled): Copy to clipboard
How to make a page full width (no side columns but header and body): Liquid-widthWeb pages can be liquid-width (using 100% of the browser viewport from left to right) or fixed-width (using some part of the total width). Bootstrap uses a container class div to limit the width of the web page's content to 1170px (default) in the center of the screen. But sometimes, for the graphic design or other reason, we want to have one or more page sections that don't have this width limitation. See Liquid-width section in page Add wiki syntax in Custom code text areas of Look & FeelCopy to clipboard
Add JavaScript tracking codeSee Piwik example. Add your own PHP codeYou can add PHP to Smarty using the php smarty tag, but for this to work, you need to deactivate the Smarty Security (which is on by default). A safer and better way is to Create your own Smarty plugin. Add Post-It NotesSee Custom Code HowTo - Post-It Notes Add a top-level menuUntil Tiki6tiki-admin.php?page=look -> General Layout options -> Secondary site menu custom code replace 47 with your actual menu ID Copy to clipboard
Tiki7 and aboveThis is easier now, and you can use Module menu, which you can drag & drop (and double click to edit parameters) at tiki-admin_modules.php You need to set the params to the module such as nobox=y, etc... Timed content
Dynamic content
Show the content without columnspoint your browser like this example: tiki-index_p.php?page=i18n Or use PluginAppFrame or PluginLayout Add a wiki page in module
How to Add Custom jQuery Code Using the Custom Code Textareas
DebugPut in a template or in Look & Feel custom code to have a popup with information on all the variables, at each page refresh. Copy to clipboard
Copy to clipboard
Categories used in templatesAdmin -> Category -> Categories used in templates (TPL)
How to use? Something like
To determine if an object is categorized, use: Copy to clipboard
Show or hide modules by categoryThis is a new native feature in Tiki8. Just admin any module and indicate when to hide/show as you would edit any module param... SectionCopy to clipboard
PerspectiveThe current perspective ID is not available to the templates. However, you can simply use the value of something that was overridden in this template. This could be in one of the Site identity fields. To change the menu depending on the Site title Copy to clipboard
Variables
Dynamic variablesUse current page name as contentHow to display URL param in a page or the page name or the user name Alternate view of wiki content
Rawhttp://themes.tiki.org/tiki-index_raw.php?page=Template+Tricks Middle only, useful to include in an iframehttp://themes.tiki.org/tiki-index_p.php?page=Template+Tricks Fullscreenworks for all features, not just wiki pages
related:
Slideshow
Mobile
Clearing cache
Improve communication for planned maintenance
This is the part of tiki-error_simple.php you are looking for. Section of tiki-error_simple.php Copy to clipboard
Note that all is into a <pre> tag, so don't forget the line breaks. Also, handle single quotes with care. new example message Copy to clipboard
Related |