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.

Archive /

Our old forums are still available as a read-only archive.

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

Create Navigation Menu Based on Current Page


Go to End


3 Posts   2085 Views

Avatar
S0crates9

27 Posts

25 November 2008 at 6:18am

Edited: 25/11/2008 6:23am

I am trying to isolate only the current page and it's children, showing the links on the left side.

For some reason, I am getting a complete list of links for all pages and their children.

Here are the pages in the backend:

Homepage
About
Product
  Widget1
    Details
    Specifications
    Overview
  Widget2
    Details
    Specifications
    Overview
  Widget3
Sitemap

Here is an example of what I want to show up when I am on Widget1's page:
Widget1
    Details
    Specifications
    Overview

What would I need to do to get it to display that way? I am using the current:

<ul>
 <% control Menu(1) %>
  <% if LinkorSection = section %>
   <% if Children %>
   <% control Children %>
   <h2><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"<% if is_a(RedirectorPage) %> target="_blank" <% end_if %>><span>$MenuTitle</span></a></h2>
   <% end_control %>
   <% end_if %>
  <% end_if %>
 <% end_control %>
</ul>

Thanks for anyone's help on this!

Avatar
grilldan

Community Member, 135 Posts

25 November 2008 at 7:18am

try changing it from "Menu(1)" to "Menu(2)", and keep everything else the same.

Avatar
S0crates9

27 Posts

25 November 2008 at 7:44am

Thanks Grilldan!

I actually tried something else that seemed to work:

<ul>
<% control Level(2) %>
<li><h2><a class="$LinkingMode" href="$Link" title="Go to the $Title.XML page"><span>$MenuTitle</span></a></h2>
<% if Children %>
<ul>
<% control Children %>
<li><a class="button" style="text-decoration:none;" onclick="this.blur();" href="$Link" title="Go to the $Title.XML page"><span>$MenuTitle</span></a></li>
<% end_control %>
<% end_if %>
<% end_control %>
</ul>
</ul>

Thanks though, every time I see a different way of putting navigational item logic together, the more it makes sense...