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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Sub Menus


Reply

5 Posts   763 Views

Avatar
JustinErswell

19 November 2009 at 12:33am Community Member, 1 Post

Hi Everyone

I have a template that has a sub page type, which has a menu which is on level 3. this menu in the design is within a separate div tag what <%%> controls would I need to wrap around this to get it only to display the child objects of the parent which is a level 2 page?

Cheers

Justin

Avatar
dalesaurus

19 November 2009 at 3:14pm Community Member, 283 Posts

Hmmm this is a hierarchy fun-time problem. You need to traverse up to the parent and get it's menus

<% control Parent %>
<% control Menu(1) %>

<% end_control %>
<% end_control %>

Avatar
banal

19 November 2009 at 8:33pm Community Member, 901 Posts

I think it should rather be

<% control Parent %><!-- move scope to parent -->
<% control Children %><!-- iterate over parents children -->

<% end_control %>
<% end_control %>

Menu(1), Menu(2) etc. are global. No matter where you call them, they always return the first, second etc. level of pages.

Avatar
patjnr

19 November 2009 at 10:30pm Community Member, 101 Posts

reference http://doc.silverstripe.org/doku.php?id=built-in-page-controls&s=page%20controls

try to control your levels which returns the current section you are in.
its scope is limited as compared to Menu which is global

ta

Avatar
dalesaurus

20 November 2009 at 4:32pm Community Member, 283 Posts

Ahhh, yeah overlooked that with Menu(). Those guys are smart (and righter)