Search code examples
phpsmartysmarty3smarty2

Trouble with Smarty Template Engine


I am Having Trouble with Smarty. I need to do some calculations, Assignments, and Deletions in the .tpl file i.e. smarty. But the problem I am facing is that when ever I do {$idlist[$iSum+1]} It gives Error. here $idlist is an array and $iSum is a an Integer. It works fine with {$idlist[$iSum]} or {$idlist[3]} but gives error in {$idlist[$iSum+1]}
What must be the syntax to run some statement like this {$idlist[$iSum+1]} ?


Solution

  • Try it this way

    {assign var="iSum" value=$iSum+1}
    

    since you also want to use mathematical operation template side, Also read smarty math function