Skip Ribbon Commands
Skip to main content

SharePoint Cross Site Collection Common Top Navigation

 

James Strugnell

14/03/2012

A recent requirement was called for a SharePoint solution that would allow for cross site collection navigation in large farms.

The main issue was the administration of the navigation as there were 20+ site collections meaning that they all had to be changed one by one. This raised a few issues, time, effort required and consistency.

The farm used a common master page though-out, but they wanted a number of site collections to use the out of the box navigation and then others to use the common navigation.
The solution we came up with was to utilise the ASP.Net site map provider with the SharePoint navigation control within the master page. This solved the problem of having multiple places to edit, but raised a few new ones. As the navigation would not change often this was not a big problem, but it was the ability to change the navigation. Every time you would want to change the navigation then a solution upgrade would have to be performed.

The following is how to implement this as a Visual studio solution:

1. Create a copy of your existing masterpage and add it to the project.

2. Create Assets folder then a folder called Masterpages add the masterpage here.

3. On the Master Page find the following control.

<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">

         <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">

                 <SharePoint:AspMenu

                          ID="TopNavigationMenuV4"

                          Runat="server"

                          EnableViewState="false"

                          DataSourceID="topSiteMap"

                          AccessKey="<%$Resources:wss,navigation_accesskey%>"

                          UseSimpleRendering="true"

                          UseSeparateCss="false"

                          Orientation="Horizontal"

                          StaticDisplayLevels="2"

                          MaximumDynamicDisplayLevels="2"

                          SkipLinkText=""

                          CssClass="s4-tn"/>

                  <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">

                          <Template_Controls>

                                   <asp:SiteMapDataSource

                                            ShowStartingNode="False"

                                            SiteMapProvider="SPNavigationProvider"

                                            id="topSiteMap"

                                            runat="server"

                                            StartingNodeUrl="sid:1002"/>

                          </Template_Controls>

                 </SharePoint:DelegateControl>

         </asp:ContentPlaceHolder>

</asp:ContentPlaceHolder> 

4. Replace the above code with this:

            <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
            
                        
            <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
            
                                
            <SharePoint:AspMenu
            
                                         
            ID="TopNavigationMenuV4"
            
                                         
            Runat="server"
            
                                         
            EnableViewState="false"
            
                                         
            DataSourceID="topSiteMap"
            
                                         
            AccessKey="<%$Resources:wss,navigation_accesskey%>"
            
                                         
            UseSimpleRendering="true"
            
                                         
            UseSeparateCss="false"
            
                                         
            Orientation="Horizontal"
            
                                         
            StaticDisplayLevels="2"
            
                                         
            MaximumDynamicDisplayLevels="4"
            
                                         
            SkipLinkText=""
            
                                         
            CssClass="s4-tn"/>
            
                                
            <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource1">
            
                                         
            <Template_Controls>
            
                                                  
            <asp:SiteMapDataSource
            
                                                           
            ShowStartingNode="True"
            
                                                           
            SiteMapProvider="CustomTopNavProvider"
            
                                                           
            id="topSiteMap"
            
                                                           
            runat="server" 
            />
            
                                         
            </Template_Controls>
            
                                
            </SharePoint:DelegateControl>
            
                        
            </asp:ContentPlaceHolder>
            </asp:ContentPlaceHolder> 

5. Note that the provider has changed to the customTopNavProvider, configuring the ASPMenu control also allows you to have more control over the Navigation.

6. Save the file and add the following to the Elements.xml of the feature so that the master page is referenced:

            
               <Module Name="Masterpage and Page Layouts" List="116" Url="_catalogs/masterpage" >
    <File Type="GhostableInLibrary" 
Path="Assets\Masterpages\citricCommonNav.master" 
Url="citricCommonNav.master" />
</Module>

7. Add feature event receiver, on feature activated there is an addition to the Web Config that will reference the site map provider, when deactivated this is then removed.

            public override void FeatureActivated(SPFeatureReceiverProperties properties)
            {   
                SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent;
                webConfigMod(true, webApp);
            }
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
            {
                SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent;
                webConfigMod(false, webApp);
            }
            private void webConfigMod(bool addOrRemove, SPWebApplication webApp)
            {
                SPWebConfigModification modifyWebConfig = new SPWebConfigModification();
                modifyWebConfig.Path = "configuration/system.web/siteMap/providers";
                modifyWebConfig.Name = "add[@name=\"CustomTopNavProvider\"]";
                modifyWebConfig.Sequence = 0;
                modifyWebConfig.Owner = "add[@name=\"CustomTopNavProvider\"]";
                modifyWebConfig.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                modifyWebConfig.Value = "<add name=\"CustomTopNavProvider\" 
             siteMapFile=\"/_layouts/1033/Citric/SiteMapProvider/CustomTopNavMenu.sitemap\" 
             type=\"System.Web.XmlSiteMapProvider,System.Web, 
             Version=2.0.0.0, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a\"/>";

     if (addOrRemove)

                {
                    webApp.WebConfigModifications.Add(modifyWebConfig);
                }
                else
                {
                    for (int c = webApp.WebConfigModifications.Count - 1; c >= 0; c--)
                    {
                        if (webApp.WebConfigModifications[c].Owner == "add[@name=\"CustomTopNavProvider\"]")
                        {
                            webApp.WebConfigModifications.Remove(webApp.WebConfigModifications[c]);
                        }
                    }
                }
                webApp.Update();
                webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
            }

8. Add a SharePoint mapped Layouts folder and create the structure as followed.

TEMPLATE  -> LAYOUTS -> 1033 -> CITRIC -> SiteMapProvider

9. Add a new sitemap document to the SiteMapProvider folder.

10. The base document should look something like this:

            
               <?xml version="1.0" encoding="utf-8" ?>
            
               <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
            
                 <siteMapNode url="/" title="Citric" description="">
            
                   <siteMapNode url="/Home" title="Home" description="" />
            
                   <siteMapNode url="/Services" title="Services" description="" >
            
                     <siteMapNode url="/Consultancy" title="Consultancy" description="" />
            
                     <siteMapNode url="/Development" title="Development" description="" />
            
                     <siteMapNode url="/Hosting" title="Hosting" description="" />
            
                     <siteMapNode url="/Support" title="Support" description="" >
            
                       <siteMapNode url="/SubSupport" title="SubSupport" description="" />
            
                     </siteMapNode>
            
                   </siteMapNode>
            
                   <siteMapNode url="/Solutions" title="Solutions" description="" />
            
                   <siteMapNode url="/Case Studies" title="Case Studies" description="" />
            
                   <siteMapNode url="/Citric Blog" title="Citric Blog" description="" />
            
                   <siteMapNode url="/Clients" title="Clients" description="" />
            
                   <siteMapNode url="/About" title="My Business" description="">
            
                   </siteMapNode>
            
                   <siteMapNode url="/search" title="Search" description="" />
            
                 </siteMapNode>
            
               </siteMap>

11. Once all packaged up as a solution, all that is required is to select the common masterpage (edited and deployed above) and your common navigation feature activated.


 About us

Fuse Collaboration Services is a Cloud Solution Provider and Microsoft Gold Partner specialising in delivering SharePoint, Skype for Business, and Azure cloud-based solutions. Based in Northampton, UK.

Microsoft Gold Partner Logo showing 5 competencies

Read more

 Latest Tweets

 Latest Blog

 

 

Better Mobile 4G and the Portable Office3089<p class="lead">​​<img class="img-responsive float-right" src="/ourblog/Blog%20Site%20Images/OneDrive-for-Business-App.png" alt="OneDrive for Business App" style="max-width&#58;300px;margin&#58;5px;" />Transport for London’s (TfL) plans to roll out 4G across the London Undergound network are continuing apace, with the <a href="http&#58;//www.cityam.com/287267/tfl-moves-step-closer-offering-4g-mobile-coverage-tube-2019" target="_blank">recent news</a> that this will likely include the new Elizabeth Line (aka CrossRail) and the planned C​rossRail 2 and Northern Line extension projects.</p><p>Suppliers and interested parties have had until July 6th to submit a selection questionnaire, which will then be evaluated before a more thorough tender goes out in early August.</p><p>City AM reports that companies will be competing to construct a commercial fibre optic network and the provision of a public WiFi service in specified TfL stations. The plan Is for the first stations to get connected during 2019, taking the capital one step closer to being a fully mobile working environment.​</p><p>WiFi already exists in some Tube stations, as it does on large parts of the train network across the country – even if the actual internet speeds vary widely depending on whereabouts you are!</p><p>Both TfL and the train companies will be heavily promoting the virtues of this type of connectivity for both leisure and work use, and it is popular here in the East Midlands, where we have a mixture of commuters heading into either London or Birmingham and companies who have to travel to see their clients.</p><p>But in the same way as nothing can beat the quality of a film that is already downloaded to your device, you need to make sure you have the processes and protocols in place for your mobile working to make sure you do not lose​ work unnecessarily. After all, there is nothing more frustrating than concentrating hard for an hour, only to see your work disappear because the saving process has not worked properly!</p><div class="well well-lg bg-color4 lead"><p>Here are Fuse’s top tips for your mobile working&#58;</p><ol><li>Make sure you have OneDrive syncing in place, so that when you save your document to your device it will automatically update onto your online OneDrive folder as soon as you are back online, thereby ensuring that your company work remains up-to-date<br></li><li>Do not get too reliant on having internet connectivity when you are on the move. Access to online resources may not be available for the duration of your whole journey, and even if your device is connected to the on-train WiFi the actual internet speeds will vary depending on whereabouts you are, or if you are in a tunnel<br></li><li>Have processes and checklists in place – even if they are just your own individual way of working, not official company policy – to ensure that you always download what you need onto your machine before you travel<br></li></ol></div>​ <p class="lead">Here at Fuse we believe that having the wherewithal to work effectively on the move is an integral part of the modern office. This includes OneDrive syncing being set up on all your machines, working with you to develop robust working practices for all your staff, and proactively making sure that your IT provision works to meet your needs, not the other way around.</p><div class="well well-lg"><p class="lead">Get in touch to find out how we can make sure that you have the great IT provision your organisation deserves! Call 01604 797979 or <a href="/_layouts/15/FIXUPREDIRECT.ASPX?WebId=4fc45909-2b6d-48b9-bcf9-a446e9d472d6&amp;TermSetId=c98895cd-d37f-4406-9cff-5480b4f829b6&amp;TermId=218eb0be-10f6-490a-82a7-a7fd47c8de90">send us an enquiry​​​</a></p>​ </div> | Chris Wearmouth | 693A30232E777C6675736563735C632E776561726D6F757468 i:0#.w|fusecs\c.wearmouth18/07/2018 23:00:002018-07-18T23:00:00ZAs better 4G rolls out across the nation how are you going to make your office truly mobile?As better 4G rolls out across the nation how are you going to make your office truly mobile?16/10/2018 23:15:466261htmlFalseaspx

 Contact us

Our address
12 Brookfield, Duncan Close
Moulton Park, Northampton
NN3 6WL
P: +44(0)1604 797979
Contact Us