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.

Template Questions /

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

Submenu always showing ?


Go to End


3 Posts   2579 Views

Avatar
sabumnim

Community Member, 3 Posts

4 January 2011 at 1:09am

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

Avatar
bartvanirsel

Community Member, 96 Posts

4 January 2011 at 8:16am

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

Avatar
sabumnim

Community Member, 3 Posts

5 January 2011 at 8:18am

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