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.

Template Questions /

Displaying all children links except current?


Reply


3 Posts   1121 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, 5513 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! =)