Jump to:

3395 Posts in 977 Topics by 853 members

Template Questions

SilverStripe Forums » Template Questions » start position of the loop

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

Page: 1
Go to End
Author Topic: 518 Views
  • felito
    Avatar
    Community Member
    10 Posts

    start position of the loop Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: start position of the loop Link to this post

    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) %>

  • felito
    Avatar
    Community Member
    10 Posts

    Re: start position of the loop Link to this post

    Thanks. Exactly what i need.

    518 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.