Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Create Navigation Menu Based on Current Page

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

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

Page: 1
Go to End
Author Topic: 1664 Views
  • S0crates9
    Avatar
    27 Posts

    Create Navigation Menu Based on Current Page Link to this post

    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!

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: Create Navigation Menu Based on Current Page Link to this post

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

  • S0crates9
    Avatar
    27 Posts

    Re: Create Navigation Menu Based on Current Page Link to this post

    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...

    1664 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.