Velocity foreach count, even/odd
Hello,
I have two sets of images (one is white, the other is red) that I need to alternate between in a foreach loop. Is there a way that Velocity can do this, maybe by display one image if the foreach count is odd, and the other image if it is even? Thanks in advance.
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 15 Jan, 2014 10:08 PM
Hi Ashley,
You should be able to accomplish this by using the
$_MathTool.mod()
method and$foreach.index
. Try something like the following and let me know how it works out:Note: depending on your use case, you may nee to switch the two colors around.
Please let me know if you have any questions.
Thanks!
2 Posted by Ashley Williams on 15 Jan, 2014 10:20 PM
That's just what I needed, thank you!
Ashley Williams closed this discussion on 15 Jan, 2014 10:20 PM.