通过模板更改设置 {/programmers/advanced-features/.template.settings}
通常,你可以通过修改Smarty类变量来配置 Smarty 设置。此外,你还可以使用Smarty函数注册插件、过滤器等。对 Smarty 对象所做的修改将对所有模板全局有效。
然而,Smarty 类变量和函数可以被单个模板对象访问或调用。对模板对象所做的修改只会应用于该模板及其包含的子模板。
<?php
$tpl = $smarty->createTemplate('index.tpl);
$tpl->cache_lifetime = 600;
//或者
$tpl->setCacheLifetime(600);
$smarty->display($tpl);
?>
<?php
$tpl = $smarty->createTemplate('index.tpl);
$tpl->registerPlugin('modifier','mymodifier');
$smarty->display($tpl);
?>