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

LinkingMode current and section


Go to End


4 Posts   4317 Views

Avatar
moonchild100

Community Member, 18 Posts

28 May 2011 at 12:25pm

Edited: 28/05/2011 12:28pm

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>

Avatar
Willr

Forum Moderator, 5523 Posts

28 May 2011 at 6:38pm

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.

Avatar
moonchild100

Community Member, 18 Posts

28 May 2011 at 8:18pm

Thanks Willr, that works :)

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

Avatar
Willr

Forum Moderator, 5523 Posts

29 May 2011 at 11:04am

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.