17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 8977 Views |
-
Quick question about showing different navigation levels (solved I think)

9 December 2007 at 9:14pm Last edited: 10 January 2008 10:48pm
Just a quick question about enabling navigation levels with SS. I understand the control structures as depicted in the first tutorial. I can make pages that show the second level of navigation (or whatever level, being handled by <% control Menu(2) %>). But if I want to show the second navigation level at all times, but with each second level navigation menu belonging to its main navigational parent? An example of this would be css drop-down menus as described in articles like <http://www.alistapart.com/articles/horizdropdowns/>... How would I do that with SS? Can it be done with the standard menu page controls? If so, I don't see how, but perhaps anybody else does?
Many thanks for your reply!
(edited because of probable solution)
-
Re: Quick question about showing different navigation levels (solved I think)

9 December 2007 at 11:19pm
There's probably an easier way.
But if there are just 2 or 3 levels max I'd just do something like this ..
Sorry 'bout the pseudo code.. :
// Get all top level menu-tems)
DataObject::get("SiteTree", "ShowInSearch = 1 AND ParentID=0");// Loop through them
foreach (toplevel-menu-item) {// get all children for this menu-item
DataObject::get("SiteTree", "ShowInSearch = 1 AND ParentID= current-menu-itemID");// Loop through the children as well
foreach (2ndlevel-menu-item) {// do - stuff
}}
Good luck !
-
Re: Quick question about showing different navigation levels (solved I think)

9 December 2007 at 11:27pm
Thanks Fuzz10!
I figured it needed some custom coding... I will try something like this (although I'm not sure my current coding skills allow for that, but hey, I should start somewhere ;)
Thanks!
-
Re: Quick question about showing different navigation levels (solved I think)

10 January 2008 at 10:46pm
Maybe I solved my little problem (and slapping my forehead for not seeing this) and is this the easier way indeed (example of simplified code):
<ul id="mainnav">
<% control Menu(1) %>
<li><a href="$Link">$MenuTitle</a><ul id="subnav">
<% control Children %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul></li><% end_control %>
</ul>This works and it doesn't break, no forbidden nested page controls either... or do I miss something?
-
Re: Quick question about showing different navigation levels (solved I think)

26 January 2008 at 1:50pm
I've been trying to figure out the same thing. I tried your code that you came up with and all I get is empty sub-menus.
<div id="menu">
<ul id="nav-one" class="nav"><li class="current"><a href="/silverstripe/home/" title="Go to the "Home" page">Home</a>
<ul class="sfHeader"></ul>
</li><li class="link"><a href="/silverstripe/about-us/" title="Go to the "About Us" page">About Us</a>
<ul class="sfHeader"></ul>
</li><li class="link"><a href="/silverstripe/contact-us/" title="Go to the "Contact Us" page">Contact Us</a>
<ul class="sfHeader"></ul>
</li></ul>
</div>This is the template code I use.
<div id="menu">
<ul id="nav-one" class="nav">
<% control Menu(1) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a>
<ul class="sfHeader">
<% control Menu(2) %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul></li>
<% end_control %>
</ul>
</div> -
Re: Quick question about showing different navigation levels (solved I think)

26 January 2008 at 2:12pm
Never mind on my inquiry. I changed
<% control Menu(2) %> to <% control Children %> and everything's good.
| 8977 Views | ||
|
Page:
1
|
Go to Top |


