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

Include section page in navigation


Go to End


1053 Views

Avatar
Rodskagg

Community Member, 26 Posts

20 November 2012 at 12:30am

Is there an easy way to also include the parent section page in a navigation?

Let's say I have this structure:

- Section 1
- - Subpage 1
- - Subpage 2
- - Subpage 3
- Section 2

If I'm on Subpage 2, or pages below this page, I want the navigation to show:

  • Section 1
  • Subpage 1
  • Subpage 2 (marked as active)
  • Subpage 3

But Menu() only lists the sub pages. Do I have to "manually" include the section page in the nav, or is there a setting, or parameter, of some kind I can use?

At the moment, I'm writing out the link to the parent section using Level(1), which sort of works, but surely there must be a better way to handle this scenario?

(Also, I'm having difficulties marking the current page/section as active. I set .current and .section links to bold, but if I'm on for example Subpage 2, both this page and the link to Section 1 will be bold, since the Subpage 2 link will have the .current class, while the Section 1 link has the .section class. And if I'm on a page below the Subpage 2 page, both the Subpage 2 and Section 1 links will have the .section class, and therefore both marked as active/bold.)