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

Pos and modulo


Go to End


2 Posts   2090 Views

Avatar
g

Community Member, 22 Posts

6 November 2008 at 2:03am

I need to highlight every third record returned to a template. I'm using this syntax:

<% control getMemberProjects %>

<% if Pos%3==0 %>
<b>$name</b>
<% end_if %>

<% end_control %>

There is no way to perform modulo or anything more complex than equality with the if statement in the template. Any ideas how to handle this?

Avatar
Fuzz10

Community Member, 791 Posts

6 November 2008 at 3:17am

A solution would be to alter your dataobjectset in your class by using the customise function (http://api.silverstripe.com/sapphire/view/ViewableData.html#customise).

It is a kind of dirty hack , but you could for example add a booleon to your dataobjectset which you use in the template to decide whether or not to hi-lite the row.

Good luck !