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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Problem with <%if > control


Go to End


19 Posts   12255 Views

Avatar
Willr

Forum Moderator, 5523 Posts

18 June 2010 at 6:50pm

Ask and you shall receive - http://doc.silverstripe.org/templates#modulus_and_multipleof.

We're trying to be proactive with the docs. A huge effort is taking place to rebuilt and rewrite, tidy up so if you see something missing that should be documented (like this) throw up a ticket to open.silverstripe.org. We will be dealing with those in the coming months.

I personally at least get carried away with new features and code and because I know it, everyone else must know it but I'm attempting to change such bad habits

Avatar
kcd

Community Member, 54 Posts

8 October 2010 at 12:15pm

Edited: 08/10/2010 12:15pm

Modulus and multipleof are great. I'm trying to use them to detect the first and last items in a row of four columns, but...

This works:

<% if MultipleOf(4) %> I'm a multiple of 4 <% end_if %>

This doesn't:

<% if MultipleOf(4, 3) %> Anything as a second parameter breaks <% end_if %>

I cannot see why I cannot pass the second parameter, anyone?

Avatar
rob.s

Community Member, 78 Posts

17 November 2011 at 11:44pm

Edited: 17/11/2011 11:46pm

Agree to kcd's issue. Same Problem. Inside a loop

the following works:
(every 3rd Element starting by 1 => 1,4,7,10....)

{$MultipleOf(3,3)}

the following does not:
(results in Parse error: syntax error, unexpected '}' in....)

<% if MultipleOf(3,3) %>

Any ideas would be great ...

Go to Top