Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

<% if Odd %> doesn't work


Go to End


1259 Views

Avatar
gakenny

Community Member, 153 Posts

7 December 2007 at 11:44pm

Hello,

I have been trying to use <% if Odd %> to alternate background colours of a list. This works for the first and second entries. However, the third and greater entries have the same background colour as the second entry.
<% if Odd %>
<tr class="bg_colour1">
<% else %>
<tr class="bg_colour2">
<% end_if %>

However, <% if Even %> works fine and provides an alternative method to achieve the same result.
<% if Even %>
<tr class="bg_colour2">
<% else %>
<tr class="bg_colour1">
<% end_if %>

Anyone experienced the same issue?

Cheers,

Gary