Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Dividing up menu items

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

Page: 1
Go to End
Author Topic: 1169 Views
  • sca123
    Avatar
    Community Member
    61 Posts

    Dividing up menu items Link to this post

    Basically I need to take the total number of second level menu items and divide by 4. This would equal X.

    I would then loop the second level menu options in groups of X, so for example, if the number of second level menu items was 23, I would have 4 groups of 5 + 1 group of 3. (5 groups)

    The output needs to be as the following example:

    [group 1]
    <div class="red_info_link">
    <ul>
    <li>[menu item 1]</li>
    <li>[menu item 2]</li>
    <li>[menu item 3]</li>
    <li>[menu item 4]</li>
    <li>[menu item 5]</li>
    </ul>
    </div>
    [group 2]
    <div class="red_info_link">
    <ul>
    <li>[menu item 6]</li>
    <li>[menu item 7]</li>
    <li>[menu item 8]</li>
    <li>[menu item 9]</li>
    <li>[menu item 10]</li>
    </ul>
    </div>

    etc.. etc..

    [group 5]

    <div class="red_info_link">
    <ul>
    <li>[menu item 21]</li>
    <li>[menu item 22]</li>
    <li>[menu item 23]</li>
    </ul>
    </div>

    Any help on this would be appreciated.

  • sca123
    Avatar
    Community Member
    61 Posts

    Re: Dividing up menu items Link to this post

    I found this that may be of some help..

    [link]http://www.ssbits.com/manipulating-every-nth-item-in-a-control-loop/[/link]

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