none
single Master Page pointing to different sitemap based on subsite opened RRS feed

  • Question

  • Hi all,

    Is there any possibulity that we can have a single master page pointing to differnet sitemap based on the subsite created.

    <asp:SiteMapDataSource   ShowStartingNode="False"  SiteMapProvider="TopMenuNavSiteMapProvider"        id="topMenuNavSiteMapDataSource"  runat="server"/>

    Can anyone help on this...

    Monday, July 9, 2012 9:23 AM

Answers

All replies

  • Hi,

    Usually the SiteMapDataSource element is placed in a DelegateControl in the master page - something like this (default v4.master):

    <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>

    To change the SiteMapDataSource control you need to overwrite the DelegateControl from the master page, in which your SiteMapDataSource is placed in.  

    You can find a clear explanation of how the control substitution works in this article: Using a Custom Data Source for Navigation.

    Cheers,

    Dan.


    You can find my blog here: http://developertrack.blogspot.com

    Monday, July 9, 2012 10:55 AM
  • Hi Dan,

    Thanks for reply...

    for ex: I am having 3 sitemaps, Home.sitemap, subsite1.sitemap and subsite2.sitemap and one master page.
    and I want to append different sitemaps to the same master page based on the site opened.

    here i am applying one sitemap but i need to apply sitemap dynamically based on site opened. but this below will show the same sitemap for all pages.

    <asp:ContentPlaceHolder id="TopMenuNav" runat="server">
         <SharePoint:AspMenu
             ID="topMenuNavAspMenu"
             Runat="server"
             EnableViewState="false"
             DataSourceID="topMenuNavSiteMapDataSource"
             AccessKey="<%$Resources:wss,navigation_accesskey%>"
             UseSimpleRendering="true"
             UseSeparateCss="false"
             Orientation="Horizontal"
             StaticDisplayLevels="1"
             MaximumDynamicDisplayLevels="3"
             SkipLinkText=""
             CssClass="s4-tn"/>
           <SharePoint:DelegateControl runat="server" ControlId="CustomXmlContentMapProvide" Id="TopMenuNavDelegate">
            <Template_Controls>
             <asp:SiteMapDataSource
               ShowStartingNode="False"
               SiteMapProvider="TopMenuNavSiteMapProvider"
               id="topMenuNavSiteMapDataSource"
               runat="server"/>
            </Template_Controls>
           </SharePoint:DelegateControl>
           </asp:ContentPlaceHolder>

    Monday, July 9, 2012 11:23 AM
  • Hi,

    I understand - you need to do is overwrite the  TopNavigationDataSource DelegateControl.

    An example can be found in the samples you can download from here: SharePoint 2010 101 Code Samples (\SharePoint 2010 Developing Delegate Controls\C#\UI_DelegateControl).

    In the code behind of the Control you can put your logic for setting a different SiteMapDataSource depending on what site you are on.

    Cheers,

    Dan.


    You can find my blog here: http://developertrack.blogspot.com

    Monday, July 9, 2012 11:45 AM
  • Hi Dan,

    Sorry to say we are not allowed to custimize or write code. Every thing showld be done in Masterpage.., Sharepoint designer or in configuration .

    No C# or VB.net code.

    Monday, July 9, 2012 11:57 AM
  • Hi,

    Then you need to create a separate master page for each type of site you are using.

    I don't see any other way of doing it without any code customization.

    Cheers,

    Dan.


    You can find my blog here: http://developertrack.blogspot.com

    Monday, July 9, 2012 12:11 PM
  • Hi Dan,

    Then is it not possible to configure this using sharepoint designer by writing javascript in the master page. If possible let know ... Thanks


    Monday, July 9, 2012 12:43 PM
  • Hi Asif,

    You can refer to this article add JavaScript on master page.

    http://labs.steveottenad.com/adding-javascript-to-sharepoint-2010-master-page/

    Thanks,

    Jack

    Wednesday, July 11, 2012 10:05 AM
    Moderator