Instance tutorial
<Html>
<Head>
<Title >{$ title }</title>
</Head>
<Body>
{Include file = 'page _ header. tpl '}
{* Body of template goes here, the $ tpl_name variable
Is replaced with a value eg 'contact. Tpl'
*}
{Include file = "$ tpl_name.tpl "}
{Include file = 'page _ footer. tpl '}
</Body>
</Html>
{Include} passing variables
{Include file = 'links. tpl 'title = 'newest link' links = $ link_array}
{* Body of template goes here *}
{Include file = 'footer. tpl 'foo = 'bar '}
Output
<Div id = "box">
<H3> {$ title} {/h3>
<Ul>
{Foreach from = $ links item = l}
... Do stuff...
</Foreach}
</Ul>
</Div>
<Body>
{Include file = 'Nav. tpl 'assign = navbar}
{Include file = 'header. tpl 'title = 'smarty is cool '}
{$ Navbar}
{* Body of template goes here *}
{$ Navbar}
{Include file = 'footer. tpl '}
</Body>
Example 7-20. Various {include} resource examples
{* Absolute filepath *}
{Include file = '/usr/local/include/templates/header. Tpl '}
{* Absolute filepath (same thing )*}
{Include file = 'File:/usr/local/include/templates/header. tpl '}
{* Windows absolute filepath (MUST use "file:" prefix )*}
{Include file = 'File: C:/www/pub/templates/header. tpl '}
{* Include from template resource named "db "*}
{Include file = 'DB: header. tpl '}
{* Include a $ variable template-eg $ module = 'contacts '*}
{Include file = "$ module. tpl "}
{* Wont work as its single quotes ie no variable substitution *}
{Include file = '$ module. tpl '}
{* Include a multi $ variable template-eg amber/links. view. tpl *}
{Include file = "$ style_dir/$ module. $ view. tpl "}