21491 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1148 Views |
-
Menu Subitems

26 January 2009 at 6:41pm
Hi,
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 Page.ss, as like in the following example:-Main
--Products
--ProdA
--ProdB
--Services
--ServA
--ServB -
Re: Menu Subitems

26 January 2009 at 11:45pm Last edited: 26 January 2009 11:55pm
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 %>
-
Re: Menu Subitems

28 January 2009 at 6:01am
Will try that out man. Thanks.
Is that the only / most efficient way?
-
Re: Menu Subitems

28 January 2009 at 8:57am
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.
-
Re: Menu Subitems

2 December 2009 at 10:49am
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?
TIA
-
Re: Menu Subitems

2 December 2009 at 2:01pm
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?
| 1148 Views | ||
|
Page:
1
|
Go to Top |





