Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Display whole content of submenu

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

Page: 1
Go to End
Author Topic: 139 Views
  • othello
    Avatar
    Community Member
    3 Posts

    Display whole content of submenu Link to this post

    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

  • camfindlay
    Avatar
    Forum Moderator
    148 Posts

    Re: Display whole content of submenu Link to this post

    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

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