Multiple Sitemaps

Globalization

A problem that i found lately was when i needed to have multiple sitemaps. Why? I needed different menus for different parts of the website. Normally, the sitemap must be found at the root of the website. After searching, I found this solution which is very easy to implement… Next are the steps:

1. In web.config, you can add multiple site map providers, and set the siteMapFile property.

    <siteMap defaultProvider=”XmlSiteMapProvider” enabled=”true”>
      <providers>
        <add siteMapFile=”web.sitemap” name=”XmlSiteMapProvider” type=”System.Web.XmlSiteMapProvider” securityTrimmingEnabled=”true”/>

 <add siteMapFile=”my.sitemap” name=”MyXmlSiteMapProvider” type=”System.Web.XmlSiteMapProvider” securityTrimmingEnabled=”true”/>

      </providers>
    </siteMap>

2 In a page, add a SiteMapDataSource, set the SiteMapProvider to you have configurated in the config file

<asp:SiteMapDataSource ID=”SiteMapDataSource1″ runat=”server” SiteMapProvider=”MyXmlSiteMapProvider” />

3. Bind you treeview or menu control to this datasource control.

Hello, nice to meet you

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

2 Comments

Leave a Reply