Normally subsites are displayed in a dropdown menu when the site collection publishing feature is activated.
In this post I will show you how to display these subsites on their own navigation row. The end result is shown in the picture below.
Hide the subsites dropdown menu
First you need to hide the subsites dropdown menu from the global navigation.
- Open your custom master page or a duplication of the “v4.master” master page in code view.
- Do a search on “TopNavigationMenuV4”. This is the standard global navigation menu.
- Set the “MaximumDynamicDisplayLevels” attribute to “0”;
Add the a new sitemap data source
The new sitemap data source is used to retrieve the subsites from the parent site. The following code can be added after global navigation menu.
|
|
The most important attribute in the code is “StartingNodeOffset”. This attribute needs to be set to “1” to show the underlying subsites. If set to zero, the parent sites will be displayed.
Add a new asp menu
This menu will use the newly created sitemap datasource.
|
|
The code needs to be added after the global navigation menu.
Add some styling to the navigation row
|
|
Result
That is all, so you see it is fairly simple to add a new navigation level to your master page. The cool part about it, is that the subsite navigation will only be show if the parent site contains subsites.