I have a simple site where some pages are actually just containers of sub-pages. When one of these main pages is selected in the main navigation menu (which is in a sidebar), I actually show the first subpage, using this technique in the Page subclass:
$url=Director::baseURL().$this->Children()->First()->URLSegment;
Director::redirect($url);
I also display on the page a submenu of the subpages, so the user can move among them, with the current page selected. All has worked well so far. Now I want to move this submenu to be nested within the main menu item, so that when the user clicks a page with subpages, the submenu appears below the main page item. But it's not working for me. Before I had basically this:
Main nav menu:
<% control Menu(1) %>
<li class="$LinkingMode">
<% if LinkingMode = link %>
<a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a>
<% else %>
<span>$MenuTitle</span>
<% end_if %>
</li>
<% end_control %>
For the submenu:
<% if Menu(2) %>
<div id="Submenu">
<ul id="Menu2">
<% control Menu(2) %>
<li class="$LinkingMode">
<% if LinkingMode = current %>
<span>$MenuTitle</span>
<% else %>
<a href="$Link" title="Go to the $Title page">$MenuTitle</a>
<% end_if %>
</li>
<% end_control %>
</ul>
</div>
<% end_if %>
This was working. What doesn't work is this:
<% control Menu(1) %>
<li class="$LinkingMode">
<% if LinkingMode = link %>
<a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a>
<% else %>
<span>$MenuTitle</span>
<% end_if %>
<% if Menu(2) %>
<div id="Submenu">
<ul id="Menu2">
<% control Menu(2) %>
<li class="$LinkingMode">
<% if LinkingMode = current %>
<span>$MenuTitle</span>
<% else %>
<a href="$Link" title="Go to the $Title page">$MenuTitle</a>
<% end_if %>
</li>
<% end_control %>
</ul>
</div>
<% end_if %>
</li>
<% end_control %>
That is, with the submenu nested within the parent li. Nothing shows up in the output. So what's different, what do I need to do to get this to work? I'm sure it's something basic to do with my understanding of levels.