Knowledgebase : Version 3.2 > Smarty Template Reference

Templating Elevated X using the Smarty Templating Language

About Smarty:

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
What this means for the Elevated X CMS is that the CMS provides data to the templates.  Smarty is what controls the formatting of this data.

Smarty Syntax:

You can find out more about Smarty syntax here:
http://www.smarty.net/

You can find out more about basic smarty syntax here:
http://www.smarty.net/docsv2/en/language.basic.syntax.tpl

Template Files:

By default, the template that the system uses is based on the name of the file that's being called.  For instance:
gallery.php uses /cms_admin/<smartyfolder>/gallery.tpl
index.php uses /cms_admin/<smartyfolder>/index.tpl
category.php uses /cms_admin/<smartyfolder>/category.tpl

Tours generally use the file tour1.tpl.

Data:

Almost universally, all data will come from a variable called $root.  $root includes all of the data that is passed to the smarty template system.  You can see a dump of this information by doing:

<pre>
{$root|@print_r}
</pre>

Of course, this is a daunting amount of information.  Sometimes, you will only be interested in an element that exists under root.  In this case, you can either do:

1) Print just that element:
<pre>
{$root.page.comingsoon|@print_r}
</pre>

2) Use the object browser (debug=root).  More information about this is listed below.

Includes:

Our CMS templates do not include the entire page's logic within one single template file.  Instead, we split the logic into separate files that can be then "included" into the template using the include tag.

Here's an example from index.tpl:

{foreach from=$root.page.comingsoon.item item=item}
<li class="coming_soon_item">{include file="$spath/index/comingsoon_item.tpl" item=$item}</li>
{/foreach}

Here's what this piece of code does:

    •    {foreach}: This tag cycles through what is known as an array.  In this case, the array is $root.page.comingsoon.item.

    •    item=item: For each set within $root.page.comingsoon.item, store the value temporarily within a variable called $item

    •    {include file="$spath/index/comingsoon_item.tpl" item=$item}.  This will call out to a separate template.  It will pass along the variable $item, so it can be used in that sub-template.


Elevated X commands that will help:

1) highlevelcachedebug=1

By adding this to a page URL, you will see vital caching information, such as which template folder is in use:

e.g: http://allaccess.elevatedx.com/members/?highlevelcachedebug=1
e.g: http://allaccess.elevatedx.com/members/gallery.php?id=171&type=vids&highlevelcachedebug=1

Here, you'll be able to see that the "smartyfolder" for this site is "smarty0".  This maps to the path:
/cms_admin/smarty/smarty0/

within the CMS.

2) debug=root

By adding this to your page URL as a PHP argument, you'll be able to see the whole contents of $root, along with some documentation on what each element does.

e.g: http://yoursite.com/members/?debug=root
e.g: http://yoursite.com/members/gallery.php?id=171&type=vids&debug=root

Note: We don't allow browsing the $root tag on our CMS demo since we have mod_security installed.  If you are getting an "Internal Server Error" when trying to browse $root, please contact your host.