4

I have following smarty code on my template

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

When I print both variable $smarty.capture.diff and $smarty.const.UPDATE_BLOCK_SECONDS, they output correct value (for example 98969 and 86400), but the {if} statement does not works and always print value "disable update"

Star
  • 3,222
  • 5
  • 32
  • 48
Prakash
  • 2,749
  • 4
  • 33
  • 43

2 Answers2

4

please try

{if 0+$smarty.capture.diff > 0+$smarty.const.UPDATE_BLOCK_SECONDS}
  enable update
{else}
  disable update
{/if}

or

{if (int)$smarty.capture.diff > (int)$smarty.const.UPDATE_BLOCK_SECONDS}
  enable update
{else}
  disable update
{/if}
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
1
{capture name="diff"}
    {datediff timestamp=$data_base.updated_date}
{/capture}

contains whitespace.

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

might be what you're looking for.

rodneyrehm
  • 13,442
  • 1
  • 40
  • 56
  • what I found is that `{(int)$smarty.capture.diff}` prints value 0 that's why it always return false. Still looking for a help to solve this issue :( – Prakash Mar 25 '12 at 19:01