Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » Level 2 menu control with isCurrent

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

Page: 1
Go to End
Author Topic: 3492 Views
  • Bambii7
    Avatar
    Community Member
    254 Posts

    Level 2 menu control with isCurrent Link to this post

    HI all,
    I'm getting there slowly, but really slowly. I'm begging to understand templates and sitetree a little more. I'm am having major trouble with setting up a permanent sub menu, a question I see a few others asking with a few different solutions.

    I've got ye old main menu running horizontally along the header. And a sub menu running down the side with all the children of home to appear on all pages. So far so good. Now I'm having trouble identifying the current active menu to then display a third level menu. The boolean isCrruent gives me errors can you even use this in an <% if isCrruent %> statement?

    the code

    <ul id="nav">
       <% control Menu(2) %>
          <% if Children %>
              <li id="nav"><div><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></div>
              <ul>
                   <% control Children %>
                    <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></li>
                   <% end_control %>
                </ul>
                </li>
          <% else %>
           <li id="nav"><div><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></div></li>
          <% end_if %>
       <% end_control %>
    </ul>

    I was trying to do the following but my noobness got me stumped

    <ul id="nav">
       <% control Menu(2) %>
          <% if Children %>
    <% if isCurrent %>
              <li id="nav"><div><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></div>
              <ul>
                   <% control Children %>
                    <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></li>
                   <% end_control %>
                </ul>
                </li>
    <% end_if %>
          <% else %>
           <li id="nav"><div><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></div></li>
          <% end_if %>
       <% end_control %>
    </ul>   

    Any ideas? I've been working on this for an embarrassing long amount of time. I was originally trying use the sitemap() function form the tutorial. Then realised the default controls should be capable of managing this.

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Level 2 menu control with isCurrent Link to this post

    OK am I correct in thinking this will work?
    <% if LinkingMode = current %>

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Level 2 menu control with isCurrent Link to this post

    Sorry to be self posting, here is where I got to yesterday. Lernt a whole bunch but still haven't managed to get it on every page. I'm assuming I'll have to build some sort of page controler?

    <ul id="menutwo">
    <% control Menu(2) %>
    <% if LinkingMode = current %>
    <li class="navlvl1 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% control Children %>
    <li class="navlvl2 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% end_control %>
    <% else_if LinkingMode = section %>
    <li class="navlvl1 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% control Children %>
    <li class="navlvl2 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% if LinkingMode = current %>
    <% control Children %>
    <li class="navlvl3 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% end_control %>
    <% else_if LinkingMode = section %>
    <% control Children %>
    <li class="navlvl3 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% end_control %>
    <% end_if %>
    <% end_control %>
    <% else %>
    <li class="navlvl1 $LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% end_if %>
    <% end_control %>
    </ul>

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