21286 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1215 Views |
-
Dynamic drop down menus

27 March 2009 at 5:35am
Hello again SilverStripe world,
I'm using the following code to pull the first level of my Nav:
<ul>
<% control Menu(1) %>
<li><a class="$LinkingMode" href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a></li>
<% end_control %>
</ul>Pretty straight forward. I need now to go a step further and also have it pull my level 2 items if they exist. Here is what in my mind should work:
<ul>
<% control Menu(1) %>
<li><a class="$LinkingMode" href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a>
<% if Menu(2) %>
<ul>
<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title page">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>Is this the best way to go about doing this? Of course coupled with the right css to make drop drop down show or hide.
thanks!
-
Re: Dynamic drop down menus

28 March 2009 at 7:51am
This looks fine. If you were really nitpicking, I guess you could put the sub navigation into its own include file. But that might be pushing it.
Looks great!
-
Re: Dynamic drop down menus

30 March 2009 at 8:19pm
You should use the "Children" control for the sub-menu. Menu(2) won't work inside a Menu(1) control.
Best - Roman
| 1215 Views | ||
|
Page:
1
|
Go to Top |


