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

Displaying all children links except current?


Go to End


3 Posts   1979 Views

Avatar
Jay-Dee

Community Member, 11 Posts

24 February 2011 at 11:24am

Hello all!.
I have a multi level navigation site. what I am trying to do is to show a "Also in this section" menu below my current content. So far I have managed to do this by using the following code:

	<h1>Also in $Level(1).Title</h1>

  <ul><% control Menu(2) %>

<li><a class="navigation"  href="$Link" title=" Go to $Title.XML">$MenuTitle</a></li>

 
  <% end_control %></ul>
 
 	</div>
<% end_if %>

However, this code displays a list of all children, but I want my current page to be excluded from this list. Is there a simple code I can use to achieve this? Thanks in advance!

Avatar
Willr

Forum Moderator, 5523 Posts

24 February 2011 at 8:16pm

Wrap your li in a <% if LinkOrCurrent = Link %>...<% end_if %> $LinkOrCurrent will return 'link' or 'current'.

http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls

Avatar
Jay-Dee

Community Member, 11 Posts

25 February 2011 at 5:28am

Ohh, Lovely! Thank you Will! =)