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.

Customising the CMS /

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

Nested menus


Go to End


6 Posts   3170 Views

Avatar
mrwindupbird

Community Member, 26 Posts

1 November 2009 at 5:46am

Edited: 01/11/2009 5:47am

I'm not sure if this is the right forum for this, but here goes...

I am designing a site that needs nested sub-menus. For example, I have setup "MusicHolder" and "MusicPage" pages. Under the main MusicHolder page, I have a link to another MusicHolder page for a band. Now we're two MusicHolder pages in, and what's next is all the albums by this one band... but the list of "MusicPage" albums aren't listed in the 2nd MusicHolder submenu.

e.g.

-MusicHolder (Click here to see the list of bands)
--MusicHolder (This is a cool band)
---MusicPage (This is the cool band's first album)
---MusicPage (This is the cool band's second album)
---MusicPage (This is the cool band's third album)

etc. etc...

So from the 2nd MusicHolder page, the sub-menu does not list the MusicPage pages with the list of albums... what to do??

Avatar
bummzack

Community Member, 904 Posts

1 November 2009 at 7:11am

I'm not sure if I really understand what you're trying to do.. the structure you provided as example should be easy to do. To output sub-pages in the template, simply use the "Children" control? Eg. <% control Children %>

Avatar
mrwindupbird

Community Member, 26 Posts

1 November 2009 at 7:52am

It may well be quite easy to do... this is the first website I've tried to make, so I'm struggling against a steep learning curve at the moment.. Would the <% control Children %> tag go in the MusicPage.ss layout file?

Avatar
bummzack

Community Member, 904 Posts

3 November 2009 at 7:46pm

Well, it depends where your list should appear. If you want a list like proposed in your first post, you would build it using the Children control on the MusicHolder Page template to list the MusicPages.

You can also output it like a navigation, so that it's always visible, no matter where you currently are on the site:

<% control Menu(1) %>
	$Title <!-- MusicHolder -->
	<% control Children %>
		$Title <!-- MusicHolder Children, eg. cool band -->
		<% control Children %>
			$Title <!-- MusicPage -->
		<% end_control %>
	<% end_control %>
<% end_control %>

This is just an uncluttered example, but the generated markup might not really be useful. You should add some <ul> and <li> tags and of course links in there.

Avatar
Naren

Community Member, 21 Posts

19 September 2013 at 7:53am

Hi all,

I was looking for nested menu module for silverstripe 3.0

can anyone suggest me for the same.

Thanks in advance

Avatar
Webdoc

Community Member, 349 Posts

21 September 2013 at 9:35am

Banal answered your question but in SS2.4 way so if u have 3.0 replace all 'control' with 'loop'. Example - <% loop Menu(1) %><% end_loop %>

---------------------------------------------------------------------------------------------------------------------------------------------------------------
Arvixe Web Hosting / SilverStripe Community Liaison | Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!