Smarty - variable addition

RSK picture RSK · Jul 23, 2011 · Viewed 22.5k times · Source

I want to add a constant value to a variable in smarty. just like:

{assign var='c' value='0'}
$c=$c+1

Answer

duality_ picture duality_ · Aug 4, 2011

Try this:

{assign var='c' value=0}
{assign var='c' value=$c+1}

The short form should work too, but you say it doesn't.

{$c=0}
{$c=$c+1}

But this doesn't work because you're using Smarty 2, right? Because in Smarty 3 it should work.