4

テンプレートに以下の smarty コードがあります

{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}

variable$smarty.capture.diff$smarty.const.UPDATE_BLOCK_SECONDSの両方を出力すると、正しい値 (98969 と 86400 など) が出力されますが、{if} ステートメントは機能せず、常に値「disable update」が出力されます。

4

2 に答える 2

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}
于 2012-03-24T09:49:00.370 に答える
1
{capture name="diff"}
    {datediff timestamp=$data_base.updated_date}
{/capture}

空白が含まれています。

{capture name="diff"}{datediff timestamp=$data_base.updated_date}{/capture}

あなたが探しているものかもしれません。

于 2012-03-25T15:09:57.397 に答える