|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
DigiMonkey Smarty n00b
Joined: 24 Oct 2014 Posts: 1
|
Posted: Fri Oct 24, 2014 10:53 pm Post subject: How to use "cycle" value? |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Oct 25, 2014 2:17 pm Post subject: |
|
|
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 |
|
|
|
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
|