Get Smarty

Donate

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Visit www.sport-kick.com for cheap soccer cleats, sneakers and Soccer Jerseys updates

Advertisement

修改模板设置

通过你会通过修改Smarty 成员变量 来修改Smarty的设置。 此外,你还可以通过Smarty 函数 来注册插件、过滤器等等。 Smarty对象的修改将是全局的。

然而你也可以通过单独的模板对象来修改Smarty的成员变量或调用函数。 模板对象的修改将只会作用于当前模板和其包含的子模板。

Example 17.4. 创建模板对象并修改Smarty的设置


<?php
$tpl = $smarty->createTemplate('index.tpl');
$tpl->cache_lifetime = 600;
//或者
$tpl->setCacheLifetime(600);
$smarty->display($tpl);
?>

    


Example 17.5. 创建模板对象并注册插件


<?php
$tpl = $smarty->createTemplate('index.tpl');
$tpl->registerPlugin('modifier','mymodifier');
$smarty->display($tpl);
?>

    


Comments
No comments for this page.

Advertisement