我在模板上有以下智能代码
{capture name="diff"}
{datediff timestamp=$data_base.updated_date}
{/capture}
{$smarty.capture.diff} | {$smarty.const.UPDATE_BLOCK_SECONDS}
{if $smarty.capture.diff > $smarty.const.UPDATE_BLOCK_SECONDS}
enable update
{else}
disable update
{/if}
当我同时打印变量$smarty.capture.diff
和$smarty.const.UPDATE_BLOCK_SECONDS
时,它们输出正确的值(例如98969和86400),但{if}语句不起作用并始终打印值“禁用更新”< / p>
答案 0 :(得分:4)
请尝试
{if 0+$smarty.capture.diff > 0+$smarty.const.UPDATE_BLOCK_SECONDS}
enable update
{else}
disable update
{/if}
或
{if (int)$smarty.capture.diff > (int)$smarty.const.UPDATE_BLOCK_SECONDS}
enable update
{else}
disable update
{/if}
答案 1 :(得分:1)
{capture name="diff"}
{datediff timestamp=$data_base.updated_date}
{/capture}
包含空格。
{capture name="diff"}{datediff timestamp=$data_base.updated_date}{/capture}
可能就是你要找的东西。