One great feature that I don’t see used all to often is include templates. These give you the ability to break your template down into small workable sections and include them as needed. For the latest site I built I used these in lots of places and it made my job a whole lot easier.
Include templates can be used for anything and I have seen them used for headers, footers, sidebars, etc. But what brings you lots of power is to use include templates inside loops, assigning them to variables, and adding variables to the includes.
Includes In Loops
Take for example the showlistings template file. The standard one has a foreach loop which handles displaying the listings in a table. It looks like this:
{foreach from=$results item="entry"}
{$entry.title}
{/foreach}
To convert this to an include you would do this:
{foreach from=$results item="entry"}
{include file="inc/inc_results.tpl" entry=$entry}
{/foreach}
Then in your inc/inc_results.tpl file add the part that would be looped over:
{$entry.title}
{$entry.price|format_money}
Of course this is very basic but if you have an advanced layout for your internal items then this is a life saver in simplifying it.
Assign Includes
Another wonderful feature is assigning an include file. This can be done like this:
{include file='inc/inc_sidebar.tpl' assign=navbar}
Then any where else in your template you need the side bar you would just add:
{$navbar}
This is really helpful if you have something that needs to be shared. For example at the top a list of links and then in the footer that same list.
Includes With Variables
The final section to this post is including a file with variables. For this lets pretend we are creating a header include. A common header needs a title, keywords, and description. So your include would look like this:
{include file="inc/inc_header.tpl" title="Your Title" keywords="key,word,here" description="Description Here"}
Then in your template:
<title>{$title}</title>
<meta name="Keywords" content="{$keywords}" />
<meta name="Description" content="{$description}" />
Hopefully this post will show the great flexibility in the 68 Classifieds template system and give you ideas in making your templates easier to manage.
