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.

Template Questions

Problem with <%if > control


Reply

19 Posts   8675 Views

Avatar
Willr

18 June 2010 at 6:50pm Forum Moderator, 5511 Posts

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

8 October 2010 at 12:15pm (Last edited: 8 October 2010 12:15pm), Community Member, 54 Posts

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

17 November 2011 at 11:44pm (Last edited: 17 November 2011 11:46pm), Community Member, 78 Posts

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 ...