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.

General Questions /

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

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

Show Top Level Page on any SubPage (SOLVED)


Go to End


3 Posts   3997 Views

Avatar
Hello_electro

Community Member, 80 Posts

7 September 2009 at 2:12pm

Edited: 07/09/2009 4:53pm

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

Forum Moderator, 5523 Posts

7 September 2009 at 2:41pm

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

Community Member, 80 Posts

7 September 2009 at 4:52pm

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!!!