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

Dividing menu items into groups

Go to End

10 Posts   5258 Views


Community Member, 61 Posts

3 August 2009 at 8:28am

Has anyone got any further thoughts on this? 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">
<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>
[group 2]
<div class="red_info_link">
<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>

etc.. etc..

[group 5]

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

Any help on this would be appreciated.


Community Member, 3 Posts

11 May 2013 at 6:25am

Go to Top