foreach help

covort

New member
Is there a way of me finding out which cycle of the loop i am currently on.

For example:

Code:
<xen:foreach loop="$RecentNews" value="$news">
<div class="{xen:if '{$loop.cyclenumber} % 2 == 1', 'primaryContentDark', 'primaryContent'}">
</xen:foreach>
 
Rich (BB code):
<xen:foreach loop="$RecentNews" value="$news" i="$i" count="$count">
<div class="{xen:if '{$loop.cyclenumber} % 2 == 1', 'primaryContentDark', 'primaryContent'}">
</xen:foreach>

Now {$i} will increment for each iteration. {$count} will just have the total number of array elements.
 
t
Rich (BB code):
<xen:foreach loop="$RecentNews" value="$news" i="$i" count="$count">
<div class="{xen:if '{$loop.cyclenumber} % 2 == 1', 'primaryContentDark', 'primaryContent'}">
</xen:foreach>

Now {$i} will increment for each iteration. {$count} will just have the total number of array elements.
Thank you :)
 
Back
Top Bottom