Posts mit dem Label Foundation werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Foundation werden angezeigt. Alle Posts anzeigen

Mittwoch, 7. September 2011

How to change the order in the SharePoint Foundation alternative SPSiteMapProvider

I was trying to improve the navigation for a customer without investing to much in money and time. I found a solution discribed in this blog:
Easy and Simple SharePoint 2010 Dropdown Navigation bar that works no scripts, no web.config, works on hosted providers

In summary: go to the masterpage and replace this part:
<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"/>
    <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>

with this:
<SharePoint:AspMenu
 ID="SPSiteMapProvider"
 Runat="server"
 EnableViewState="false"
 DataSourceID="SiteMapDataSource1"
 AccessKey="<%$Resources:wss,navigation_accesskey%>"
 UseSimpleRendering="true"
 UseSeparateCss="false"
 Orientation="Horizontal"
 StaticDisplayLevels="2"
 MaximumDynamicDisplayLevels="3"
 SkipLinkText=""
 CssClass="s4-tn"/>
 <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1"/>
<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
 <Template_Controls>
 <asp:SiteMapDataSource
 ShowStartingNode="False"
 SiteMapProvider="SPSiteMapProvider"
 id="topSiteMap"
 runat="server"
 StartingNodeUrl="sid:1002"/>
 </Template_Controls>
</SharePoint:DelegateControl>
Unfortunately this Navigation provider sort the Items using ASCII order. He don't care about the order defined in the ToNavigationConfiguration interface.

So how can I sort the sites anyhow? Just add whitespaces to the title of the Web that you want to be on the first. Example:

Pages with the titles "First", "Second", "Third", "Fourth" and "Fifths" will be shown in this order:
"Fifths", "First", "Fourth", "Second", "Third"
To get them in the right order change the name to this:
"    First", "   Second", "  Third", " Fourth" and "Fifths"

And don't worry the whitespaces are trimmed in both the Navigation and the Page title.

It's not the most elegant way, but it works.

Enjoy and share