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

start position of the loop


Go to End


3 Posts   1772 Views

Avatar
felito

Community Member, 10 Posts

28 February 2013 at 2:08pm

Edited: 28/02/2013 2:34pm

I have this code, and if the pagetype is page, i want to start the loop at the position 4. I am trying $modulus, but the result is not the expected.

This should be simple, right?

<% if ClassName = Page %>
<% loop $Menu(1) %>
<% if not $Modulus(5) %>
<li class="$LinkingMode triangle-isosceles top buble-$Pos">
<a href="$Link" title="$Title.XML">$MenuTitle.XML</a>
</li>
<% end_if %>
<% end_loop %>
<% end_if %>

Avatar
Willr

Forum Moderator, 5523 Posts

28 February 2013 at 8:48pm

Modulus doesn't work like that (http://en.wikipedia.org/wiki/Modular_arithmetic).

If you want to alter the start to skip the first 4, one way you could do is use Limit() - <% loop $Menu(1).Limit(100, 4) %>

Avatar
felito

Community Member, 10 Posts

1 March 2013 at 11:28am

Thanks. Exactly what i need.