1

Why would a <SharePoint:AspMenu> control behave one way on publishing pages & another way on non-publishing pages?

I have a custom master page on a publishing site. I would like to remove the welcome page link from the top nav. Merely setting ShowStartingNode="False" to the topSiteMap datasource control wasn't doing it. I found a blog post that said that the topSiteMap datasource was getting overridden by a delegate control, so i created my own delegate control.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Sequence="40" 
           Id="TopNavigationDataSource" 
           ControlClass="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapDataSourceSwitch"
           ControlAssembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="ID">topSiteMap</Property>
    <Property Name="SiteMapProvider">GlobalNavigation</Property>
    <Property Name="EnableViewState">false</Property>
    <Property Name="StartFromCurrentNode">false</Property>
    <Property Name="ShowStartingNode">false</Property>
    <Property Name="TreatStartingNodeAsCurrent">false</Property>
    <Property Name="TrimNonCurrentTypes">Heading</Property>
  </Control>
</Elements>

That seemed to work, but as you would expect, that shifted all of the elements up one level (i.e. static elements at level 2 are now static elements at level 1, dynamic elements at level 3 are now static elements at level 2). So back in my master page, I set StaticDisplayLevels="1" & MaximumDynamicDisplayLevels="2" on the TopNavigationMenuV4 AspMenu 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="1" 
                        MaximumDynamicDisplayLevels="2" 
                        SkipLinkText="" 
                        CssClass="s4-tn"/>


    <SharePoint:DelegateControl runat="server" 
                                ControlId="TopNavigationDataSource" 
                                Id="topNavigationDelegate">
      <Template_Controls>
        <asp:SiteMapDataSource ShowStartingNode="False" 
                               SiteMapProvider="GlobalNavigation" 
                               id="topSiteMap" 
                               runat="server" 
                               EnableViewState="false" 
                               StartFromCurrentNode="true"/>
      </Template_Controls>
    </SharePoint:DelegateControl>
  </asp:ContentPlaceHolder>
</asp:ContentPlaceHolder>

That fixed all publishing pages, but it had no affect on any of the non publishing pages (lists, libraries, site settings, etc).

I tried to replace the <asp:SiteMapDataSource> control with a <PublishingNavigation:PortalSiteMapDataSourceSwitch> control just like the delegate control, but that didn't work. I checked all my page layouts to make sure i wasn't overriding either the PlaceHolderTopNavBar or PlaceHolderHorizontalNav placeholders.

I am not sure what i am missing. Why would publishing pages act like StaticDisplayLevels="1" MaximumDynamicDisplayLevels="2" & non publishing pages act like StaticDisplayLevels="2" MaximumDynamicDisplayLevels="3"?

Thank you for your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.