Controlling Cacheability
of Plugins' Output on how to use them properly.
$cacheable 和 $cache_attrs
参数在大多数情况下可以省略。它们的使用方法可以查看控
制插件输出的缓存。
Example 13-22. register_function
例子 13-22. 注册函数
$smarty->register_function("date_now", "print_current_date");
function print_current_date ($params) { extract($params); if(empty($format)) $format="%b %e, %Y"; return strftime($format,time()); }
// now you can use this in Smarty to print the current date: {date_now} // or, {date_now format="%Y/%m/%d"} to format it.
// 现在你可以在模板中这样显示日期:{date_now} // 或者用{date_now format="%Y/%m/%d"}的格式进行格式化
|
|