Tuesday, April 24, 2012

Hiding the First Top-Link Tab for a Publishing SharePoint Site

After enabling the SharePoint Server Publishing Infrastructure feature on a SharePoint site the first tab in the top-link bar automatically changes to the site title:

Here is an example of a site before the publishing infrastructure has been enabled:

This is what the site looks like after enabling the feature (I also changed the site title to further illustrate the problem):

This can be a very undesirable result when the site title is long or just undesirable as the first tab's label.  With a few masterpage changes this behavior can be remedied.  To accomplish this follow these steps:

Open the site in SharePoint Designer and go to the Master Pages left navigation. 
Make a copy of the "v4.master" and rename it to something like "modified.master":


The first step is to edit your new "modified.master" and add the following line to the Registers at the top of the master page:

<%@ Register 
 Tagprefix="PublishingNavigation" 
 Namespace="Microsoft.SharePoint.Publishing.Navigation" 
 Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
%>


Further down in the master page you will find a block of code that looks something like this:

The part of the code that we are going to focus on is the SharePoint:DelegateControl.  A good article that describes the purpose of the DelegateControl can be found here: http://msdn.microsoft.com/en-us/library/ms432695.aspx.  We are going to replace this delegate control with a control that we can customize a little bit more.  Highlight the SharePoint:DelegateControl (like shown below) and delete it:

We are going to replace the deleted text with the following:

<PublishingNavigation:PortalSiteMapDataSource 
ID="topSiteMap" 
Runat="server" 
SiteMapProvider="CombinedNavSiteMapProvider" 
StartFromCurrentNode="true" 
StartingNodeOffset="0" 
ShowStartingNode="false" 
TrimNonCurrentTypes="Heading" 
/>

This creates a new TopNav datasource.  This data source will still consume the out of the box data navigation, but will not show the first tab (created by the publishing feature).

After making this modification the top link bar the top link now looks like this:

For more information on this topic check out these other blogs:

http://blogs.msdn.com/b/ecm/archive/2007/02/10/moss-navigation-deep-dive-part-1.aspx


No comments:

Post a Comment