Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Increase Var in {section}

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
Chraensch
Smarty Rookie


Joined: 10 Sep 2003
Posts: 6

PostPosted: Wed Sep 10, 2003 11:04 am    Post subject: Increase Var in {section} Reply with quote

Hey all.

Maybe I'm just an Idiot, but I can't find a solution to this problem:

I'm trying, in a {section} loop, to increase a var but I keep failing, can anyone help me? here's the thingy:

Code:
{assign var="rep_var" value=0}
               {section name=subl loop=$headers}
                  {if $headers[subl]->parent == $headers[lp]->messageid}

                     {assign var="rep_var" value=+1} {* this is were I want to increase, I tried different methods but kept failing *}
                  {/if}
               {/section}
            {$rep_var}
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Wed Sep 10, 2003 11:09 am    Post subject: Reply with quote

In current CVS version you can use

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

Otherwise you need to use the math function

{math assign="rep_var" equation="x+1" x=$rep_var}
Back to top
View user's profile Send private message
Chraensch
Smarty Rookie


Joined: 10 Sep 2003
Posts: 6

PostPosted: Wed Sep 10, 2003 11:26 am    Post subject: Reply with quote

thank you, It works now. Used the math function as I'm not using the current CVS Version.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Sep 10, 2003 1:08 pm    Post subject: Reply with quote

just for the records: in your example you could also use {counter} or {$smarty.section.subl.index}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP