There are a lot of academic Sharepoint exercises that cover the elements of this project, but today we're going to walk through a practical integration and deployment exercise. This is a great real example of WHY you’d want to centralize master pages definitions in the first place.
One of our clients wanted to start breaking their burgeoning site hierarchy into a set of separate site collections and contents databases largely to keep their database sizes reasonable. However, their site is highly branded, so they wanted to minimize the extra admin work of synchronizing Sharepoint master pages among multiple collections. In addition, they had several changes they wanted to make to their master pages to enable Ajax-based controls on their sites. They also wanted to have all the sites point to one primary site collection to define global navigation, so that changes made there would also replicate without further administration.
For this project, we had already installed the binaries for the third party Ajax control and a custom theme for the site. Also, the Publishing infrastructure is required on all sites where this is deployed, so MOSS is a requirement.
As a result, this project became an integration and customization drawing upon several significant online code sources, We're going to cover each of these in a separate post:
· [Part I] Master page customization to add centralized navigation support to the master page. The navigation was based on Marian Dumitrascu’s article at http://www.codeproject.com/KB/sharepoint/SharedNavigationProvider.aspx
· [Part II] Centralized publishing of common master pages, using Heather Solomon’s techniques from http://heathersolomon.com/blog/articles/servermstpageforsitecollect_feature.aspx
· [Part III] Packaging of the feature as a WSP file, using the WSPBuilder application from Codeplex (http://www.codeplex.com/wspbuilder)
· [Part IV] Automated installation of the solution package, using the SharePoint Installer from Codeplex (again!) at http://www.codeplex.com/sharepointinstaller
Master Page Customization and Centralized Navigation:
Please visit http://www.codeproject.com/KB/sharepoint/SharedNavigationProvider.aspx for a comprehensive discussion of the centralized navigation.
Essentially, that article provides a DLL that you add to the Global Assembly Cache on all your servers. Once the DLL is installed, you will add a section to web.config to define a new SiteMap provider:
<add name="SharedNavigationProvider" SourceSite="http://[sourcesite]" NavigationType="Global" EncodeOutput="true" type="DataQ.SharePoint.Providers.SharedNavigationProvider, SharedNavigationProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fc448b9e121af773" />
Then you add will update your current master page(s) to add a control to point to the new navigation data source. We strongly recommend copying the content of your base master pages to a new file that lives, for the moment, outside the SharePoint site. Using SharePoint Designer to make these edits can have unintended consequences, so we’ll use notepad for now. [More below!]
Underneath the TopNavigationDataSource control, add this control noted below. TIP: don’t just replace the existing navigation data source. It needs to “live” inside the Template_Control node, and the new source needs to be outside. Lastly, you’ll update the ASPMenu navigation to point to the ID of the new data source, here “topSiteMap2”. [There are other changes that may be required for DisplayValues, etc. – please see Marian’s article for more details.
<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
<SharePoint:AspMenu
ID="TopNavigationMenu"
Runat="server"
DataSourceID="topSiteMap2"
EnableViewState="false"
AccessKey="<%$Resources:wss,navigation_accesskey%>"
Orientation="Horizontal"
StaticDisplayLevels="1"
MaximumDynamicDisplayLevels="1"
DynamicHorizontalOffset="0"
StaticPopoutImageUrl="/_layouts/images/menudark.gif"
StaticPopoutImageTextFormatString=""
DynamicHoverStyle-BackColor="#CBE3F0"
SkipLinkText=""
StaticSubMenuIndent="0"
CssClass="ms-topNavContainer">
<StaticMenuStyle/>
<StaticMenuItemStyle CssClass="ms-topnav" ItemSpacing="0px"/>
<StaticSelectedStyle CssClass="ms-topnavselected" />
<StaticHoverStyle CssClass="ms-topNavHover" />
<DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" BorderWidth="1px"/>
<DynamicMenuItemStyle CssClass="ms-topNavFlyOuts"/>
<DynamicHoverStyle CssClass="ms-topNavFlyOutsHover"/>
<DynamicSelectedStyle CssClass="ms-topNavFlyOutsSelected"/>
</SharePoint:AspMenu>
<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource">
<Template_Controls>
<asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SPNavigationProvider"
id="topSiteMap"
runat="server"
StartingNodeUrl="sid:1002"/>
</Template_Controls>
</SharePoint:DelegateControl>
<asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SharedNavigationProvider"
id="topSiteMap2"
runat="server"/>
</asp:ContentPlaceHolder>
There were some other updates that were needed to these master pages, notably adding an assembly reference and script manager for a third party Ajax control. These two lines went before the first HTML tag:
<%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>
<%@ Register TagPrefix="XXXXXX" [deleted] %>
And this line goes after the first <FORM> tag
<asp:ScriptManager runat="server" ID="ScriptManager1" />
Remember earlier when we discussed the importance of editing in Notepad? Sharepoint Designer can rewrite the src tag of the DesignModeConsole reference to remove the tilde, which causes errors when the page is deployed to the site. If you are seeing errors, make sure the wssuc tagprefix entries are properly formatted as noted above.
Comments