Question

I've seen a few posts asking similar things but nothing I can use. I am working with a SharePoint 2013 publishing site with custom master pages and layouts.

I have a vertical navigation which shows the following (numbers added to levels for clarity)

1 Resources
   1.1 Journals
      1.1.1 Request a Journal

By design when you click onto 1.1.1 the parent terms all disappear and the menu shows only the active term (1.1.1) and any children. I require a static menu that shows all terms at all times. I have several sub-sites all with the same navigation methods using different terms sets to show different sub terms in the current navigation.

On switching to a Top Navigation snippet the behavior is as desired (menu terms remaining static when clicking into sub levels) but it always uses a single term set (set at the site level)

This is the snippet for Top Navigation (using site-level single term set):

<div data-name="TopNavigationNoFlyoutWithStartNode">
            <!--CS: Start Top Navigation Snippet-->
            <!--SPM:<%@Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
            <!--MS:<SharePoint:AjaxDelta runat="server" CssClass="ms-displayInline ms-core-navigation ms-dialogHidden" BlockElement="True" ID="DeltaTopNavigation">-->
            <!--PS: Start of READ-ONLY PREVIEW (do not modify)-->
            <!--PE: End of READ-ONLY PREVIEW-->
            <!--MS:<SharePoint:DelegateControl runat="server" Id="topNavigationDelegate" ControlId="TopNavigationDataSource">-->
            <!--PS: Start of READ-ONLY PREVIEW (do not modify)--><span style="display:none"><table cellpadding="4" cellspacing="0" style="font:messagebox;color:buttontext;background-color:buttonface;border: solid 1px;border-top-color:buttonhighlight;border-left-color:buttonhighlight;border-bottom-color:buttonshadow;border-right-color:buttonshadow"><tr><td nowrap="nowrap"><span style="font-weight:bold">PortalSiteMapDataSource</span> - topSiteMap</td></tr><tr><td></td></tr></table></span>
            <!--PE: End of READ-ONLY PREVIEW-->
            <!--MS:<Template_Controls>-->
            <!--MS:<asp:SiteMapDataSource ShowStartingNode="True" SiteMapProvider="CurrentNavigation" ID="topSiteMap" runat="server" StartingNodeUrl="sid:1002">-->
            <!--ME:</asp:SiteMapDataSource>--><!--ME:</Template_Controls>-->
            <!--ME:</SharePoint:DelegateControl>-->
            <a name="startNavigation"></a>
            <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderTopNavBar" runat="server">-->
            <!--MS:<SharePoint:AspMenu runat="server" UseSeparateCss="false" AdjustForShowStartingNode="False" StaticDisplayLevels="4" AccessKey="1" SkipLinkText="" EnableViewState="False" MaximumDynamicDisplayLevels="0" UseSimpleRendering="True" DataSourceID="topSiteMap" Orientation="Vertical" ID="TopNavigationMenu">-->
            <!--PS: Start of READ-ONLY PREVIEW (do not modify)--><link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/menu-21.css" /><div id="zz7_TopNavigationMenu" class=" noindex ms-core-listMenu-verticalBox"><ul id="zz9_RootAspMenu" class="root ms-core-listMenu-root static"><li class="static"><a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/sites/library/home" accesskey="1"><span class="additional-background ms-navedit-flyoutArrow"><span class="menu-item-text">Home</span></span></a></li><li class="static"><a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="/sites/library/join-the-library"><span class="additional-background ms-navedit-flyoutArrow"><span class="menu-item-text">Join The Library</span></span></a></li><li class="static ms-verticalAlignTop ms-listMenu-editLink ms-navedit-editArea"><span class="ms-navedit-editSpan" id="zz7_TopNavigationMenu_NavMenu_Edit"><a id="zz7_TopNavigationMenu_NavMenu_EditLinks" class="ms-navedit-editLinksText" href="#" onclick="g_QuickLaunchMenu = null; EnsureScriptParams('quicklaunch.js', 'QuickLaunchInitEditMode', 'zz7_TopNavigationMenu', 4, 0, 1, ''); cancelDefault(event); return false;"><span class="ms-displayInlineBlock"><span class="ms-navedit-editLinksIconWrapper ms-verticalAlignMiddle"><img class="ms-navedit-editLinksIcon" src="/_layouts/15/images/spcommon.png?rev=23" /></span><span class="ms-metadata ms-verticalAlignMiddle">Edit Links</span></span></a><span id="zz7_TopNavigationMenu_NavMenu_Loading" class="ms-navedit-menuLoading ms-hide"><a id="zz7_TopNavigationMenu_NavMenu_GearsLink" href="#" onclick="HideGears(); return false;" title="This animation indicates the operation is in progress. Click to remove this animated image."><img id="zz7_TopNavigationMenu_NavMenu_GearsImage" src="/_layouts/15/images/loadingcirclests16.gif?rev=23" /></a></span><div id="zz7_TopNavigationMenu_NavMenu_ErrorMsg" class="ms-navedit-errorMsg"></div></span></li></ul></div>
            <!--PE: End of READ-ONLY PREVIEW-->
            <!--ME:</SharePoint:AspMenu>-->
            <!--ME:</asp:ContentPlaceHolder>-->
            <!--PS: Start of READ-ONLY PREVIEW (do not modify)-->
            <!--PE: End of READ-ONLY PREVIEW-->
            <!--ME:</SharePoint:AjaxDelta>-->
            <!--CE: End Top Navigation Snippet-->
            </div>

This is the snippet for Current Navigation (allows term sets to be set for sub-sites)

<div data-name="QuickLaunch">
                    <!--CS: Start Vertical Navigation Snippet-->
                    <!--SPM:<%@Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
                    <!--SPM:<%@Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
                    <div id="sideNavBox" class="ms-dialogHidden ms-forceWrap ms-noList">
                        <!--MS:<SharePoint:AjaxDelta runat="server" CssClass="ms-core-navigation" BlockElement="True" ID="DeltaPlaceHolderLeftNavBar">-->
                            <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBar" runat="server">-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarTop" runat="server">-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderQuickLaunchTop" runat="server">-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarDataSource" runat="server">-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderCalendarNavigator" runat="server">-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderLeftActions" runat="server">-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                                <!--MS:<SharePoint:SPNavigationManager ID="QuickLaunchNavigationManager" runat="server" QuickLaunchControlId="v4QuickLaunchMenu" ContainedControl="QuickLaunch" EnableViewState="false">-->
                                    <!--MS:<SharePoint:DelegateControl runat="server" ControlId="QuickLaunchDataSource">-->
                                        <!--MS:<Template_Controls>-->
                                            <!--MS:<PublishingNavigation:PortalSiteMapDataSource runat="server" ID="SiteMapDS" SiteMapProvider="CurrentNavigation" EnableViewState="false" StartFromCurrentNode="True" ShowStartingNode="True" TrimNonCurrentTypes="Heading">-->
                                            <!--ME:</PublishingNavigation:PortalSiteMapDataSource>-->
                                        <!--ME:</Template_Controls>-->
                                    <!--ME:</SharePoint:DelegateControl>-->
                                    <!--MS:<SharePoint:AspMenu runat="server" DataSourceId="QuickLaunchSiteMap" AdjustForShowStartingNode="False" StaticDisplayLevels="9" SkipLinkText="" EnableViewState="False" MaximumDynamicDisplayLevels="9" UseSimpleRendering="False" Orientation="Vertical" ID="V4QuickLaunchMenu">-->
                                    <!--ME:</SharePoint:AspMenu>-->
                                <!--ME:</SharePoint:SPNavigationManager>-->
                                <!--MS:<SharePoint:SPNavigationManager ID="TreeViewNavigationManagerV4" runat="server" ContainedControl="TreeView" CssClass="ms-tv-box">-->
                                    <!--MS:<SharePoint:SPLinkButton runat="server" accesskey="&#60;%$Resources:wss,quiklnch_allcontent_AK%&#62;" CssClass="ms-tv-header" ID="idNavLinkSiteHierarchyV4" NavigateUrl="~site/{0}/viewlsts.aspx" Text="Site Content">-->
                                    <!--ME:</SharePoint:SPLinkButton>-->
                                    <!--MS:<SharePoint:DelegateControl runat="server" ControlId="TreeViewAndDataSource">-->
                                        <!--MS:<Template_Controls>-->
                                            <!--MS:<SharePoint:SPHierarchyDataSourceControl runat="server" ID="TreeViewDataSourceV4" RootContextObject="Web" IncludeDiscussionFolders="true">-->
                                            <!--ME:</SharePoint:SPHierarchyDataSourceControl>-->
                                            <!--MS:<SharePoint:SPRememberScroll runat="server" ID="TreeViewRememberScrollV4" onscroll="javascript:_spRecordScrollPositions(this);" style="overflow: auto;">-->
                                                <!--MS:<SharePoint:SPTreeView ID="WebTreeViewV4" runat="server" ShowLines="false" DataSourceId="TreeViewDataSourceV4" ExpandDepth="0" SelectedNodeStyle-CssClass="ms-tv-selected" NodeStyle-CssClass="ms-tv-item" SkipLinkText="" NodeIndent="12" ExpandImageUrl="/{0}/images/tvclosed.png" ExpandImageUrlRtl="/{0}/images/tvclosedrtl.png" CollapseImageUrl="/{0}/images/tvopen.png" CollapseImageUrlRtl="/{0}/images/tvopenrtl.png" NoExpandImageUrl="/{0}/images/tvblank.gif">-->
                                                <!--ME:</SharePoint:SPTreeView>-->
                                            <!--ME:</SharePoint:SPRememberScroll>-->
                                        <!--ME:</Template_Controls>-->
                                    <!--ME:</SharePoint:DelegateControl>-->
                                <!--ME:</SharePoint:SPNavigationManager>-->
                                <!--MS:<asp:ContentPlaceHolder ID="PlaceHolderQuickLaunchBottom" runat="server">-->
                                    <hr />
                                    <!--MS:<SharePoint:ClusteredSPLinkButton runat="server" accesskey="&#60;%$Resources:wss,quiklnch_allcontent_AK%&#62;" CssClass="ms-core-listMenu-item" Permissions="ViewFormPages" ID="idNavLinkViewAllV4" NavigateUrl="~site/{0}/viewlsts.aspx" Text="All Site Content">-->
                                    <!--ME:</SharePoint:ClusteredSPLinkButton>-->
                                <!--ME:</asp:ContentPlaceHolder>-->
                            <!--ME:</asp:ContentPlaceHolder>-->
                        <!--ME:</SharePoint:AjaxDelta>-->
                    </div>
                    <!--CE: End Vertical Navigation Snippet-->
                </div>

I am able to swap the SiteMapProvider to show the corrct term set but the behaviour stays the same as current navigation. My question is which (if any) parts of the Top Navigation snippet controls which term sets are used and can these be changed to force the Top Navigation snippet to keep it's default behavior but use the same term sets as the current navigation snippet?

Était-ce utile?

La solution

Okay I think I have figured it out.

Preview a master page and go to snippets, select TOP NAVIGATION snippet and change the settings to vertical instead of horizontal display, set static/dynamic display levels to whatever you need.

Open the page layout you are working on in designer and paste in your snippet. In this section`

 <!--MS:<asp:SiteMapDataSource ShowStartingNode="True" SiteMapProvider="SPNavigationProvider" ID="topSiteMap" runat="server" StartingNodeUrl="sid:1002">-->

change SiteMapProvider to "CurrentNavigation"

<!--MS:<asp:SiteMapDataSource ShowStartingNode="True" SiteMapProvider="CurrentNavigation" ID="topSiteMap" runat="server" StartingNodeUrl="sid:1002">-->

And in settings > navigation make sure GLOBAL Navigation is set to use Managed Navigation and the term set you want to apply. Then when clicking into a child page the whole tree remains. This is what I was after.

Also I had to delete the placeholder for the top navigation bar so if this exists on the page it needs to be deleted

<!--MS:<asp:ContentPlaceHolder ID="PlaceHolderTopNavBar" runat="server">-->
        <!--MS:<SharePoint:AspMenu runat="server" UseSeparateCss="false" AdjustForShowStartingNode="False" StaticDisplayLevels="2" AccessKey="1" SkipLinkText="" EnableViewState="False" MaximumDynamicDisplayLevels="0" UseSimpleRendering="True" DataSourceID="topSiteMap" Orientation="Horizontal" ID="TopNavigationMenu">-->
            <!--PS: Start of READ-ONLY PREVIEW (do not modify)--><link rel="stylesheet" type="text/css" href="http://sptrain/_layouts/15/1033/styles/menu-21.css" /><div id="zz7_TopNavigationMenu" class=" noindex ms-core-listMenu-horizontalBox"><ul id="zz9_RootAspMenu" class="root ms-core-listMenu-root static"><li class="static ms-verticalAlignTop ms-listMenu-editLink ms-navedit-editArea"><span class="ms-navedit-editSpan" id="zz7_TopNavigationMenu_NavMenu_Edit"><a id="zz7_TopNavigationMenu_NavMenu_EditLinks" class="ms-navedit-editLinksText" href="#" onclick="g_QuickLaunchMenu = null; EnsureScriptParams('quicklaunch.js', 'QuickLaunchInitEditMode', 'zz7_TopNavigationMenu', 2, 0, 0, ''); cancelDefault(event); return false;"><span class="ms-displayInlineBlock"><span class="ms-navedit-editLinksIconWrapper ms-verticalAlignMiddle"><img class="ms-navedit-editLinksIcon" src="http://sptrain/_layouts/15/images/spcommon.png?rev=23" /></span><span class="ms-metadata ms-verticalAlignMiddle">Edit Links</span></span></a><span id="zz7_TopNavigationMenu_NavMenu_Loading" class="ms-navedit-menuLoading ms-hide"><a id="zz7_TopNavigationMenu_NavMenu_GearsLink" href="#" onclick="HideGears(); return false;" title="This animation indicates the operation is in progress. Click to remove this animated image."><img id="zz7_TopNavigationMenu_NavMenu_GearsImage" src="http://sptrain/_layouts/15/images/loadingcirclests16.gif?rev=23" /></a></span><div id="zz7_TopNavigationMenu_NavMenu_ErrorMsg" class="ms-navedit-errorMsg"></div></span></li></ul></div><!--PE: End of READ-ONLY PREVIEW-->
        <!--ME:</SharePoint:AspMenu>-->
    <!--ME:</asp:ContentPlaceHolder>-->
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top