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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Display whole content of submenu


Go to End


2 Posts   2233 Views

Avatar
othello

Community Member, 3 Posts

28 July 2014 at 5:44am

Hello,
I have a question regarding submenu content. By default SS shows in submenu list of current page children. My question is... how to display all children? Quick example:

A
- A1
- A2
-- A21
-- A22
-- A23
- A3
-- A31
B
- B1
- B2
-- B21
C
- C1

In short words... how to list children of children ...

Thanks in advance,
othello

Avatar
camfindlay

Forum Moderator, 267 Posts

28 July 2014 at 12:52pm

Are you referring to in a navigation? If so look into the $Menu template variable http://doc.silverstripe.org/framework/en/howto/navigation-menu. You can use it to recursively loop through all the child pages on the site if you pass in a bigger integer for the argument you get access to deeper levels of the nested structure e.g. $Menu(1), $Menu(2) I'd suggest having a play and experimenting to get your head around how these and template loops can work together.

You can of course also use the $Children variable while already within the scope of a Page's $Children.

<% loop $Children %>
    $Title
    <% if $Children %>
        <% loop $Children %>
            $Title
        <% end_loop %>
    <% end_if %>
<% end_ loop %>

Another option might be to look at GroupedDataList http://doc.silverstripe.org/framework/en/howto/grouping-dataobjectsets