0

Following is the smarty arithmetic code I tried but it's not working:

{if $cur_page == 1} {assign var='i' value=1} {else} {assign var='i' value=$cur_page * 15  + 1} {/if}

Can someone please correct my code? If you want any other information regarding the issue please do let me know.

PHPLover
  • 1
  • 51
  • 158
  • 311

1 Answers1

2

It simply won't work in Smarty2. In Smarty3 this code will work without a problem.

In Smarty2 you should use math() function to achieve the same so the working code in Smarty2 for that would be:

{if $cur_page == 1}
    {assign var='i' value=1}
{else}
    {math equation="x* 15 + 1" x=$cur_page assign='i'}
{/if}
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291