Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Submenu always showing ?

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

Page: 1
Go to End
Author Topic: 1522 Views
  • sabumnim
    Avatar
    Community Member
    3 Posts

    Submenu always showing ? Link to this post

    Hi all

    Completely newbie @ silverstripe so pleaz bear with me :0)

    I downloaded some of the templates from the extensions and installed them, went smoothly :0)

    However I have a question.
    If I have a submenu to both "Home" and "About", they are both showing up in the sidebar at all times, no matter if I am at "Contact" or some other page.

    I would like it to be like this:
    1) If @ "Home" show the subpages in the sidebar
    2) If @ "About" show the subpages to this page and DO NOT show all other subpage menus

    How can this be done?

    Hope to hear from you :0)

    //Carsten

  • bartvanirsel
    Avatar
    Community Member
    88 Posts

    Re: Submenu always showing ? Link to this post

    Hi Carsten,

    Advice you to read this http://doc.silverstripe.org/tutorial:1-building-a-basic-site
    and http://doc.silverstripe.org/built-in-page-controls

    Especially the part about menu controls

    <% control Menu(2) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>

    Menu(1) should give you Home and all other thing on level 1. Menu(2) should give you nested pages within first level.
    You could check which part you're in by doing something like beneath, but thats not very ellegant though.

    <% if InSection(about) %>
    <% control Menu(2) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>
    <% end_if %>

  • sabumnim
    Avatar
    Community Member
    3 Posts

    Re: Submenu always showing ? Link to this post

    Hi Bart

    Thanks for the reply, it helped me to find what I was searching for and now I have a working menu that splits into two: the main menu and the submenu and the submenu is only showing when I at the parent page :0)

    The answer was this:

    <% if Menu(2) %>
    <ul><li>
    <h2 class="$LinkingMode">$MenuTitle</h2>
    </li></ul>
    <ul id="Menu2">
    <% control Menu(2) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>

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