Loading...
 

History: Template Tricks

Preview of version: 3

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

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="pics/icons/printer.png"/>{tr}Print{/tr} </a> {/if}


Adding a "Hello John" indication

{if $user} Hello {$user} {/if}



Adding content only for a group

In content

In a template

{if $group eq "Admins"} You are a member of the group {$group} {/if}

Adding content only for a permission


Adding content only for a preference

{if $prefs.feature_wiki eq "y"} The Wiki feature is on {/if}


Display content conditional to current language

{if $prefs.language eq "fr"} <a href="accueil"> {elseif $prefs.language eq "es"} <a href="inicio"> {else} <a href="tiki-index.php"> {/if}


How to know where something is in a template?

Admin -> Look & Feel Add HTML comment at start and end of each Smarty template (TPL)

New in 3.0, turn on "log_tpl" to add comments in templates (if you click view source, you can see which tpl was used to create it

How to show content just when in certain pages

So if you want to modify tiki-searchresults.php, you find templates/tiki-searchresults.tpl

For the container

templates/tiki.tpl is the master container.

Say you want to affect the master container based on the current page, you can do

{if $mid eq "tiki-searchresults.tpl"} bla bla {/if}



Debug


Put in a template or in Site Identity to have a popup with information on all the variables, at each page refresh.

{debug}


Categories used in templates

Admin -> Category -> Categories used in templates (TPL)
(categories_used_in_tpl)

How to use? Something like

{if $objectCategoryIds eq 4} This page is in category #4 {/if}



Section

{if $section eq "blogs"} text shown just when in one of the blog pages {/if}

Perspective

You can use Site identity

History

Advanced
Information Version
Tue 16 of Mar, 2021 16:41 GMT marclaporte 88
Sat 14 of Nov, 2020 11:27 GMT jonnybradley more colours 87
Sat 14 of Nov, 2020 11:25 GMT jonnybradley adding code block colours 86
Sat 14 of Nov, 2020 11:22 GMT jonnybradley code Plugin modified by editor. 85
Sat 14 of Nov, 2020 11:21 GMT jonnybradley $group is only the default group (sometimes) but the in_group modifier checks all the groups a user might be in 84
Wed 04 of Sep, 2019 14:21 GMT marclaporte Remove ...page... that makes the page harder to use 83
Wed 04 of Sep, 2019 14:19 GMT marclaporte AutoTOC 82
Thu 03 of Nov, 2016 09:10 GMT xavi 81
Fri 26 of Jun, 2015 11:55 GMT koth 80
Tue 12 of May, 2015 21:07 GMT marclaporte 79
Tue 22 of Apr, 2014 16:37 GMT marclaporte Linking to existing docs 78
Tue 22 of Apr, 2014 16:15 GMT marclaporte Code Plugin modified by editor. 77
Tue 22 of Apr, 2014 16:07 GMT marclaporte 76
Wed 19 of Mar, 2014 01:30 GMT marclaporte How do I know which template to modify to affect the look & feel of a specific URL? 75
Wed 19 of Mar, 2014 01:23 GMT marclaporte Cosmetic 74
Tue 02 of Apr, 2013 05:41 GMT Torsten 73
Tue 09 of Oct, 2012 09:57 GMT kstingel updated image path from 'pics/...' to 'img/...' 72
Sun 29 of Jul, 2012 16:48 GMT Torsten deleted the "," and "!" from a headline (help - I broke my theme 71
Mon 28 of May, 2012 23:42 GMT marclaporte 70
Mon 28 of May, 2012 22:13 GMT marclaporte 69
Thu 09 of Feb, 2012 18:51 GMT marclaporte 68
Thu 09 of Feb, 2012 18:09 GMT marclaporte 67
Sat 04 of Feb, 2012 03:42 GMT marclaporte Code Plugin modified by editor. 66
Sat 04 of Feb, 2012 03:40 GMT marclaporte 65
Sat 04 of Feb, 2012 03:09 GMT marclaporte 64
Sat 04 of Feb, 2012 03:05 GMT marclaporte utf-8 bad conversion 63
Tue 31 of Jan, 2012 20:49 GMT Jyhem 62
Tue 31 of Jan, 2012 20:48 GMT Jyhem Code Plugin modified by editor. 61
Tue 31 of Jan, 2012 20:47 GMT Jyhem 60
Wed 09 of Nov, 2011 19:30 GMT marclaporte 59
Wed 09 of Nov, 2011 19:25 GMT marclaporte From a discussion on the mailing list (should work) 58
Thu 13 of Oct, 2011 13:02 GMT marclaporte 57
Sat 24 of Sep, 2011 17:58 GMT marclaporte 56
Sat 24 of Sep, 2011 17:54 GMT marclaporte 55
Sat 24 of Sep, 2011 17:50 GMT marclaporte 54
Tue 14 of Jun, 2011 01:48 GMT marclaporte 53
Tue 14 of Jun, 2011 01:22 GMT tinomartinez 52
Mon 13 of Jun, 2011 11:21 GMT marclaporte 51
Wed 27 of Apr, 2011 19:25 GMT marclaporte not working for some reason 50
Thu 24 of Feb, 2011 18:45 GMT marclaporte 49
Tue 11 of Jan, 2011 19:25 GMT marclaporte Thanks luci for documenting 48
Fri 05 of Nov, 2010 03:06 GMT marclaporte 47
Tue 02 of Nov, 2010 03:09 GMT marclaporte 46
Tue 02 of Nov, 2010 03:04 GMT marclaporte oups 45
Thu 28 of Oct, 2010 20:32 GMT marclaporte 44
Mon 20 of Sep, 2010 06:44 GMT marclaporte For Gaston: http://tiki.org/tiki-view_forum_thread.php?forumId=4&comments_parentId=38602 43
Sat 18 of Sep, 2010 06:28 GMT chibaguy Removed some ...page... tags - clicking 22 times to see page content isn't good usability IMHO. 42
Wed 15 of Sep, 2010 16:09 GMT ricks99 41
Thu 02 of Sep, 2010 02:09 GMT chibaguy tikiwiki to tiki in urls. 40
Sun 15 of Aug, 2010 13:02 GMT luci 39
  • «
  • 1 (current)
  • 2

Switch Theme

Layout

Latest Changes

No records to display ...more

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