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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Show Top Level Page on any SubPage (SOLVED)


Reply

3 Posts   1610 Views

Avatar
Hello_electro

7 September 2009 at 2:12pm (Last edited: 7 September 2009 4:53pm), Community Member, 80 Posts

Hi Everyone:

I have a level 2 navigation that shows up whenever you go past the main navigation links. The navigation box will show:

Main Page Title (with url)
sub page
sub page
sub page
etc

I am fine when i am 1 level deep. For example i click on About (from main nav) and choose Board Members from the drop down.

The Nav box will then show:

About
sub page
sub page
Board mmbers
etc

The problem arises when i click on Board Members. The Nav box then shows:

Board Members
sub page
sub page
Board Members
etc

What I want to show is:

About
sub page
sub page
Board Members
etc

This way, no matter how far you drill down the top header of the Nav box will always show the main link with its level 2 links below.

Here is the code I am using:

<% if Menu(2) %>
   <div id="RightNavLatestInfoContainer">
      <div id="RightNavLatestInfoTop"></div>
      <div id="RightNavLatestInfoBody">
         <div id="subnavbox">
         <% if Level(2) %>       
   <div class="subnavheader"><a href="$Parent.Link">$Parent.Title</a></div>
         <% else %>
   <div class="subnavheader"><a href="$Link">$Title</a></div>
         <% end_if %>
   <div class="RecentInfoBlocksRight">
         <ul>
            <% control Menu(2) %>
            <li class="$LinkingMode"><span class="bulletback"><a href="$Link">$MenuTitle</a></span></li>
            <% end_control %>
         </ul>
   </div>
   </div>
   </div>
<div id="RightNavLatestInfoBottom"></div><!--This is and ends the bottom image for Latest Info -->
</div><!--This ends the container for the latest info it is fluid vertically-->
<% end_if %>

I am pretty sure it has to do with my if statements and controls. I have spent 4 hours with no luck, so am turning to you guys. All I want to make sure is that the "subnavheader" div always shows the top level navigation and the "RecentInfoBlocksRight" shows the level 2 navigation no matter if I go to level 3, 4, 5 etc.

HELP!!! :)

Avatar
Willr

7 September 2009 at 2:41pm Forum Moderator, 5511 Posts

Instead of $Parent.Title which will take the parent - so always 1 level up, try $Level(2).Title or $Level(1).Title which will always return the 2nd level and 1st level title respectively.

Avatar
Hello_electro

7 September 2009 at 4:52pm Community Member, 80 Posts

Will

Thanks so much. Oddly, I tried that before, but looks like I had other code messing it up and thought maybe that option no longer worked. Thanks for clarifying, i can actually sleep tonight!!!