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.

Themes /

Discuss SilverStripe Themes.

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

Dynamic Second-level menus


Go to End


2 Posts   2659 Views

Avatar
zEkE

Community Member, 1 Post

17 December 2009 at 11:43am

Edited: 17/12/2009 11:44am

I don't often ask for help, but this one is baffling me a little.. I'm working on a website in SS, the client wants a multilevel arrangement (easy!) but wants the second levels to be available to the user when rolling the mouse over the first level (not so much..).

<ul class="Menu1">
  <% control Menu(1) %>
    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode">$MenuTitle</a></li>
  <% end_control %>
</ul>
<% if Menu(2) %>
  <ul class="Menu2">
    <% control Menu(2) %>
      <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode">$MenuTitle</a></li>
    <% end_control %>
  </ul>
<% end_if %>

So far I just have the above, and it works, but it isn't dynamic based on rollover.

I'm imagining this is going to require javascript of some level, so it would be nice to retain the above method in the event that a browser doesn't support the javascript.

To be honest I've never needed to deal with this situation, with or without SilverStripe - could this be done by putting the second-level hierarchy in a DIV and having an onMouseOver script replace the contents of it with another 2nd level menu? Either way, the problem at this point is gleaning the information for the secondary menus in such a way as I can present it in the way I need it..

Avatar
Willr

Forum Moderator, 5523 Posts

17 December 2009 at 12:46pm

Menu(2) will return the Current Pages menu, not the currently controlled objects menu 2. You should use <% control Children %> to individually get the children pages of each of the menu 1 items.