Example 7-6. function include Smarty手册范例 7-6. include 函数演示
{include file="header.tpl"}
{* body of template goes here *}
{include file="footer.tpl"}
You can also pass variables to included templates as attributes. Any variables explicitly passed to an included template as attributes are only available within the scope of the included file. Attribute variables override current template variables, in the case they are named alike.
Example 7-7. function include passing variables Smarty手册范例 7-7. 带传递参数的 include 函数演示
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
{* body of template goes here *}
{include file="footer.tpl" logo="http://my.domain.com/logo.gif"}
Use the syntax for template resources to include files outside of the $template_dir directory.