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

How to use "cycle" value?

 
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 -> General
View previous topic :: View next topic  
Author Message
DigiMonkey
Smarty n00b


Joined: 24 Oct 2014
Posts: 1

PostPosted: Fri Oct 24, 2014 10:53 pm    Post subject: How to use "cycle" value? Reply with quote

Here's my current code:

Code:
{foreach from=$items item=item name=utable}

{foreach from=$item.terms item=tmp name=titem}
<tr class="{cycle values="odd,even"}">

REMOVED UNNECESSARY CODE FROM HERE

{/foreach}
{/foreach}


The values odd and even are rotating correctly for the tr class.

However, the rotation doesn't restart with each new table - some tables start with 'even'. For example, I want the first 'tr' of every table to have the class 'odd', but if the last table ended with 'odd', the next one keeps on starting with 'even'.

Is there any way to make it the cycle stop at the end of each table and restart at the next?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Oct 25, 2014 2:17 pm    Post subject: Reply with quote

See here
Code:
{foreach from=$items item=item name=utable}

// create a named cycle which is reseted to first element
{cycle values="odd,even" name='foo' print=false reset=true advance = false}

{foreach from=$item.terms item=tmp name=titem}

// named cycle
<tr class="{cycle name='foo'}">

REMOVED UNNECESSARY CODE FROM HERE

{/foreach}
{/foreach}
Back to top
View user's profile Send private message
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 -> General 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