Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » LinkingMode current and section

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

Page: 1
Go to End
Author Topic: 1936 Views
  • moonchild100
    Avatar
    Community Member
    18 Posts

    LinkingMode current and section Link to this post

    In the following code, the <li> for level 2 will always be "current" even when I am in level 3 when the mode for level 2 parent menu should be "section" but it stays in current mode. However, if I go from level 3 to level 4, the menu of level 3 can show section and current two modes. I don't know why....maybe it's because menu(3) is using control menu while the level(2) are not?

    to make it clearer, here's how the menu bar looks like: when you are in "level(3).title" the level(2).title shows class="current" other than class="section"
    however, if like illustrated below you are in level(4), the level(3).title are in section mode

    ----------------------------------------
    level(2).title | level(3).title | level(3).title
    ---------------|---------------|----------------
    | level(4).title | level(4).title | level(4).title |

    <ul>      
       <li class="$LinkingMode">
          <a href="$Level(2).Link" title="Go to the $Level(2).Title.XML page">
             <span>$Level(2).MenuTitle.XML</span>
          </a>
       </li>

       <% control Menu(3) %>   
             <li class="$LinkingMode">
                <a href="$Link" title="Go to the $Title.XML page">
                   <span>$MenuTitle.XML</span>
                </a>
             </li>
       <% end_control %>
       
    </ul>

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: LinkingMode current and section Link to this post

    From looking at your example you're using Level(2) for level 2, but simply LinkingMode for the link mode. This will be simply using LinkingMode for the current page.

    Try

    <% control Level(2) %>
    <ul>
    <li class="$LinkingMode">
    <a href="$Link" title="Go to the $Title.XML page">
    <span>$MenuTitle.XML</span>
    </a>
    </li>

    .. remainer of your controls.

  • moonchild100
    Avatar
    Community Member
    18 Posts

    Re: LinkingMode current and section Link to this post

    Thanks Willr, that works

    so the linkingmode only works with page control not a simple link , right?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: LinkingMode current and section Link to this post

    so the linkingmode only works with page control not a simple link , right?

    No, linkingmode works everywhere, however in your example your LinkingMode was referring to the mode of the current page (which would always return current) as it wasn't nested inside any control. To get the correct level 2 menu status you had to be in the correct 'scope' of the Level(2) control.

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