多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="advanced.features.security.html">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 15. Advanced Features 高级特性</td><td width="25%" align="right" valign="bottom"> <a href="advanced.features.tem.inheritance.html">Next</a></td></tr></table> # [Changing settings by template]()[通过模板更改设置] Normally you configure the Smarty settings by modifying the Smarty class variables.Furthermore you can register plugins, filters etc. with Smarty functions. Modifications done to the Smarty object will be global for all templates. However the Smarty class variables and functions can be accessed or called by induvidual template objects.Modification done to a template object will apply only for that template and its included subtemplates. 通常,Smarty的设置是经由[Smarty类变量](#)的修改完成的。进一步,通过[Smarty方法](#)你可以注册插件、过滤器等等。Smarty对象设置的更改是全局性的,对所有模板有效。 然而,Smarty类变量和函数可被单个模板对象访问或调用。单个模板对象改变设置将只作用于该模板和其所包含的子模板。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td> <div class="EXAMPLE"> <strong><a name="AEN4154" id="AEN4154"> </a>Example 15.4. changing Smarty settings by template<br/> 例15-4.通过模板更改Smarty设置</strong><strong/> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> $tpl = $smarty-&gt;createTemplate('index.tpl);<br/> $tpl-&gt;cache_lifetime = 600;<br/> //or<br/> $tpl-&gt;setCacheLifetime(600);<br/> $smarty-&gt;display($tpl);<br/> ?&gt;</td></tr></table><p><strong>Example 15.5. register plugins by template<br/>例15-5.通过</strong><strong>模板注册插件</strong></p> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> $tpl = $smarty-&gt;createTemplate('index.tpl);<br/> $tpl-&gt;registerPlugin('modifier','mymodifier');<br/> $smarty-&gt;display($tpl);<br/> ?&gt;</td> </tr></table></div></td></tr></table> <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="advanced.features.security.html">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html">Home</a></td><td width="33%" align="right" valign="top"> <a href="advanced.features.tem.inheritance.html">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Security<br/> 安全</td><td width="34%" align="center" valign="top"><a href="smarty.for.programmers.html">Up</a></td><td width="33%" align="right" valign="top">Template Inheritance<br/> 模板继承</td></tr></table>