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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Need help with subnav

Go to End

2 Posts   1405 Views


Community Member, 1 Post

16 April 2011 at 1:40am

Hi all I want to be able to make the sub nave of the fist tab available on every page without having to replicate pages on every root section.

link -

Your help would be much appreciated




Community Member, 130 Posts

16 April 2011 at 12:02pm

Edited: 16/04/2011 12:04pm

Hi Robbie,

If you want to send people to the pages in the first section when they click the links you could generate links to the original pages in the templates using similar code to what is producing your subnav on each page, but just change 'Menu(2)' to 'Page(Your-page-URL)'. So for instance:

				<% control Page(Home) %>
					<% if Children %>
						<li><a href="$Link" title="Go to the &quot;{$Title.XML}&quot; page" class="$LinkingMode levela parent"><span>$MenuTitle.XML</span></a>
					<% else %>
						<li><a href="$Link" title="Go to the &quot;{$Title.XML}&quot; page" class="$LinkingMode levela"><span>$MenuTitle.XML</span></a>
					<% end_if %>	  
						<% if LinkOrSection = section %>
							<% if Children %>
								<ul class="sub">
									<% control Children %>
										<li><a href="$Link" title="Go to the &quot;{$Title.XML}&quot; page" class="$LinkingMode levelb"><span>$MenuTitle.XML</span></a></li>
									<% end_control %>
							<% end_if %>
						<% end_if %>
				<% end_control %>

or, you could create virtual pages in each section which point back to the pages in the first tab so that they automatically display whatever is on those pages, meaning you don't have to update multiple identical pages. This will keep the user in the relevant section unlike a Redirector page or the method above which would send them to the page in the first section.