Smartyインストールでキャッシュを有効にし、次のテンプレート関数を使用しています
function smarty_updatedhour($params, $smarty)
{
$date1 = new DateTime($params['timestamp']);
$date2 = new DateTime("now");
$interval = $date1->diff($date2);
$smarty->assign("updated_period", $interval->format('%h'), true);
}
プラグインを次のように登録しました:
$smarty->registerPlugin('function', 'updated_hour', 'smarty_updatedhour', false, array('timestamp'));
私はそれが機能しているかどうかをテストしようとしました
{updated_hour timestamp=$timestamp_vale}
{$updated_period}
{if $updated_period > 10}
// do other stuffs
{/if}
ただし、smartyページのキャッシュを無効にすると機能しません。
誰かが問題を教えてもらえますか?