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

Menu Subitems


8 Posts   1328 Views


26 January 2009 at 6:41pm Community Member, 81 Posts

I would like to know how to control a menu's subitems and choose to display a specific group in my sitetree. I would like to retrieve only the products on my menu, to a theme, as like in the following example:


Carbon Crayon

26 January 2009 at 11:45pm (Last edited: 26 January 2009 11:55pm), Community Member, 598 Posts

Provided your products are of a different page type you could do something like this:

<% control Menu(2) %>

<% if ClassName = ProductPage %>

<li> $MenuTitle etc.... </li>

<% end_if %>

<% end_control %>


28 January 2009 at 6:01am Community Member, 81 Posts

Will try that out man. Thanks.

Is that the only / most efficient way?


28 January 2009 at 8:57am Community Member, 712 Posts

If you want to ditch Menu(), you'll need to create a custom function in your page class such that:

function CustomPages($urlsegment) {
return DataObject::get("SiteTree", "some filter");

And in your tempalte

<% control CustomPages(products) %>
<li><a href="$URL">$Title</a></li>
<% end_control %>

Note that you could filter by whatever you want - so you could use a product group and a set of dataobjects, if that is more suitable.


28 January 2009 at 9:25am Community Member, 81 Posts

Thats a good idea! Thanks... will try that approach.


2 December 2009 at 10:49am Community Member, 166 Posts

Would this approach work in the following instance?

I have a site with a navigation setup for level 1 and level 2 pages. In some instances The Client wishes to have the list of sub-pages for a section appearing as a plain (bulleted) list within the page content. However in the bulk of the site the sub-pages appear within the navigation.

My initial thoughts were to use the Menu(2) control, with a condition that the Menu(2) list would only appear if the page was hidden from Navigation. However for obvious reasons this is not going to work so I need a workaround. Does anybody reading this know how to incorporate the aforementioned condition with a 'list children' kind of scenario?



2 December 2009 at 11:48am Community Member, 271 Posts


2 December 2009 at 2:01pm Community Member, 166 Posts

Hi Martijn - thanks for this! Another helpful thing to know about SilverStripe! Unfortunately it's not quite what I'm looking for - I need to show the subpages of a particular section of the site within that section, while this would give me a list of pages that I selected from throughout the site. From an admin point of view, Client would probably prefer it if this happened automatically!

You wouldn't happen to know of anything like this, would you?