Documentation Download as PDF

Template Plugins

Caribou's template system is powered by the powerful Smarty Template Engine. Smarty allows for PHP template plugins to be written and then referenced within the HTML templates. Template plugins can be stored in either the /templates/common/plugins/ or /templates/yourtemplate/plugins/ folders. Plugins in the “common” folder will load across all templates. Plugins in a particular template’s folder will only load for that particular template.

Template plugins exist as PHP files in those directories.

For more information on how to write or access Smarty plugins, visit http://www.smarty.net.

The following template plugins are included with Caribou and can be used in any template:

url – Create a URL relative to Caribou’s base install directory

Example usage in a template file:

Go to the
<a href="{url url="user/action/register"}">Registration Page</a> to signup.

formdata – Load data rows from any backend/frontend form and display them using the specified format.

Example usage in a template file (basic):

{formdata form=”3” limit=”10”}
<p>Player: [[Player Name]] – [[Goals]]</p>
{/formdata}

Example usage with sort parameters:

{formdata form="1" limit="5" sort_field="field16" sort_dir="desc"}
<p>I took a trip last [[Trip Month]] and it was [[Trip Rating]]</p>
{/formdata}

Example usage using column names as template variables (these can be seen in phpMyAdmin):

{formdata form="14" limit="1"}
Job Listing:<br /%gt;
<b>Company:</b> [[field143]]<br />
<b>Position:</b> [[field144]]<br />
<b>Salary:</b> [[field145]]
{/formdata}

restricted – Only display contents to users who are in the specified usergroup(s)

Example usage in a template file with one group:

{restricted group="1"}
This can only be seen by users in usergroup #1.
{/restricted}

Example usage with multiple usergroups that can see the contents:

{restricted group="3|4|8"}
This can be seen by anyone in any one of the 3 groups above.
{/restricted}

setting – Only show contents if the system setting equals the specified value.

Example usage in a template file:

{setting name="force_https" value="1"}
This is only seen if the force_https setting is set to
"1" or "On".  This format will work for all
Caribou settings as seen in Administration > Settings.
{/setting}

store_exists – Only display contents if the user has a store setup.

Example usage in a template file:

{store_exists}You have a store setup.{/store_exists}

activeuser – Returns a piece of JavaScript that prevents multiple simultaneous logins from one account. It is setup in all templates by default.

Example usage in a template file:

<html>
<title>My Test Page</title>
{activeuser}

analytics – Returns a piece of JavaScript that handles Google Analytics. It is setup in all templates by default.

Example usage in a template file:

{analytics}
</body>
</html>

blogarchive - Display a <ul>-formatted list of months that begins with the first post within a given topic. It's practical usage is to display a list of month links for a Blog Archive of sorts.

Example minimal usage:

Check out our blog archive!
{blogarchive topic="4"}

Example usage using all "featured on homepage" articles:

{blogarchive topic="frontpage"}

Example usage with CSS styling helpers. Sets the class and/or ID of the <ul> element.

{blogarchive topic="frontpage" class="archive_ul" id="blog_archive_id"}

cartitems - Counts the number of items in the user's shopping cart.

Example usage in a template file:

{store_exists}You have {cartitems} in your shopping cart.
<a href="{url url="user/action/register"}">Checkout now</a>.{/store_exists}

date - Displays the current date in the specified PHP format.

Look up available formats at http://www.php.net/date.

Example usage in a template file:

Today's date is {date format="Y-m-d h:i"}

flvplayer - Displays an FLV file with Caribou's included FLV player.

Example usage in a template file:

<p>Watch this video below!</p>
{flvplayer file="uploads/files/myvideo.flv"}

latest - Displays the latest X items from a given topic in a <ul>-formatted list.

Example usage in a template file:

Latest articles:
<ul>
{latest topic="5" limit="10"}

menu - Displays a menu generated by the Menu Manager.

Example minimal usage in a template file:

{menu load="top_menu"}

Example usage with CSS style helpers of class/id:

{menu load="top_menu" class="top_menu" id="the_top_menu"}

Example usage with items displayed in reverse (useful for floating items right to left):

{menu load="bottom_menu" reverse="1"}

visitor - Display data related to the logged in user.

Display the user's username:

Username: {visitor get="username"}

Display the user's last name:

{visitor get="last_name"}

Display the user's first name:

{visitor get="first_name"}

Display the user's email:

{visitor get="email"}

article - Load an article by URL string and display it.

Returns all article data as replaceable tags like [TITLE], [BODY], [DATE], [ID], etc.

Replaces tags:

  • [ID]
  • [LINK]
  • [SUMMARY]
  • [TYPENAME]
  • [TYPEID]
  • [TITLE]
  • [BODY]
  • [DATE]
  • [SHORTDATE]
  • [COMMENTSENABLED]
  • [COMMENTSCOUNT]
  • [AUTHORUSERNAME]
  • [AUTHORFIRSTNAME]
  • [AUTHORLASTNAME]
  • [AUTHOREMAIL]
  • [AUTHORGROUPID]
  • [AUTHORGROUPNAME]
  • [TOPICID]
  • [TOPICLINK]
  • [TOPICNAME]

Example:

{article url_string="my_fake_article/test"}<h2>[TITLE]</h2>
[BODY]{/article}