{include} {include} tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template. The {include} tag must have the file attribute which contains the template resource path. Setting the optional assign attribute specifies the template variable that the output of {include} is assigned to, instead of being displayed. Similar to {assign}. Variables can be passed to included templates as attributes. Any variables explicitly passed to an included template are only available within the scope of the included file. Attribute variables override current template variables, in the case when they are named the same. All assigned variable values are restored after the scope of the included template is left. This means you can use all variables from the including template inside the included template. But changes to variables inside the included template are not visible inside the including template after the {include} statement. Use the syntax for template resources to {include} files outside of the $template_dir directory. Attribute Name Type Required Default Description file string Yes n/a The name of the template file to include assign string No n/a The name of the variable that the output of include will be assigned to [var ...] [var type] No n/a variable to pass local to template Simple {include} example {$title} {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'} ]]> {include} passing variables The template above includes the example links.tpl below

{$title}{/h3>
    {foreach from=$links item=l} .. do stuff ... ]]> {include} and assign to variable This example assigns the contents of nav.tpl to the $navbar variable, which is then output at both the top and bottom of the page. {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'} ]]> Various {include} resource examples See also {include_php}, {insert}, {php}, template resources and componentized templates.