Friday, January 20, 2012

SharePoint Top navigation links read from the External file.


Get data from external file for SharePoint Top Navigation:
1.      Open the Web.config file for the SharePoint web application with a text editor such as notepad.
2.      Take copy the web.config before modifying the file.
3.      Path of the web.config is “C:\inetpub\wwwroot\wss\VirtualDirectories\80\”
4.      Add the following code in the siteMap and providers  as a last row.
<siteMap defaultProvider="CurrentNavigation" enabled="true">
      <providers>
<add name="CustomNavigationProvider" siteMapFile="/_layouts/1033/styles/CustomNavigationProvider/CustomSiteMap.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

5.      Save the Web.config and close it.
6.      Create a SiteMap file named CustomSiteMap.sitemap and put it into a new folder with the name CustomNavigationProvider. Add this folder into following directory: \14\TEMPLATE\LAYOUTS\1033\STYLES\CustomNavigationProvider

<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
 
  <siteMapNode title="" url="">
    <siteMapNode title="Home" url="/"/>
    <siteMapNode title="sitecollection1" url="/sites/sitecollection1"> </siteMapNode>
   
  <siteMapNode title="Functions">
                  <siteMapNode title="sitecollection2" url=" /sites/sitecollection1 "/>
                  <siteMapNode title=" sitecollection3" url=" /sites/sitecollection3"/>
                  <siteMapNode title="ISC" url="/sites/isc"/>
                  <siteMapNode title="IT" url="/sites/it"/>
  </siteMapNode>
 </siteMapNode>
</siteMap>

7.      Open the master page and search for the content placeholder with the id PlaceHolderHorizontalNav. Replace this placeholder with this code:

<SharePoint:AspMenu
      ID="TopNavigationMenuV4"
      Runat="server"
      EnableViewState="false"
      DataSourceID="topSiteMap"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="2"
      MaximumDynamicDisplayLevels="1"
      SkipLinkText=""
      CssClass="s4-tn"
      Visible="false"/>
    <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>
       
       
        <SharePoint:AspMenu
      ID="CustomXmlNavigationAspMenu"
      Runat="server"
      EnableViewState="false"
      DataSourceID="CustomNavigationSiteMapDataSource"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="1"
      MaximumDynamicDisplayLevels="3"
      SkipLinkText=""
      CssClass="s4-tn">
   
    </SharePoint:AspMenu>

    <!-- Second sitemap DS -->
    <SharePoint:DelegateControl runat="server" ControlId="CustomXmlMapProviderDelegateControl">
        <Template_Controls>    
            <asp:SiteMapDataSource
              ShowStartingNode="False"
              SiteMapProvider="CustomNavigationProvider"
              id="CustomNavigationSiteMapDataSource"
              runat="server" />
        </Template_Controls>
    </SharePoint:DelegateControl>

8.      Save the master page now the Top navigation read the external file. If you want add new link to the top navigation add it into the CustomSiteMap.sitemap.




No comments:

Post a Comment

Give Read Permission for SharePoint Add-in for Azure AD Send Mail to Office 365 Domain Group users.

Below are the Steps for Send Mail to Office 365 Domain Group or AD Group users from Provider Hosted ADD-IN. For this we needs to Give Permi...