register_function()
テンプレート関数プラグインを動的に登録します。
説明
voidregister_function
stringname
mixedimpl
boolcacheable
mixedcache_attrs
パラメータには、テンプレート関数
名とそれを実装する PHP のユーザー定義関数名を渡します。
&api.register.snippet;
cacheable と cache_attrs は、
ほとんどの場合に省略可能です。これらの正しい使用法についての詳細は、
キャッシュ可能なプラグインの出力の制御
を参照して下さい。
register_function()
register_function('date_now', 'print_current_date');
function print_current_date($params, &$smarty)
{
if(empty($params['format'])) {
$format = "%b %e, %Y";
} else {
$format = $params['format'];
}
return strftime($format,time());
}
?>
]]>
テンプレート
unregister_function()
および
テンプレート関数プラグイン の項も参照してください。