Ad

How To Create A Site Map Using DNN And C#

- 1 answer

My website is http://www.bodytshirt.com This site is built from DotNetNuke. It has default sitemap is http://www.bodytshirt.com/sitemap.aspx This sitemap only shows the page URL without any parameters. I want my site map to show all product in my database. Such as http://www.bodytshirt.com/product/id/141/key/i-am-a-software-engineer

Please give my suggestion. Should I create a custom sitemap for my requirement?

Ad

Answer

You can do this with the Sitemap provider in DNN. My open source DNNSimpleArticle module has an example of this:

https://github.com/ChrisHammond/dnnsimplearticle/blob/6d5d2c5bb074dd2bdede40fac4eb3c78408ab884/Providers/Sitemap/Sitemap.cs

public override List<SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
{
    var listOfUrls = new List<SitemapUrl>();

    foreach (Article ai in ArticleController.GetAllArticles(portalId))
    {

        var pageUrl = new SitemapUrl
        {
            Url = ArticleController.GetArticleLink(ai.TabID, ai.ArticleId),
            Priority = (float)0.5,
            LastModified = ai.LastModifiedOnDate,
            ChangeFrequency = SitemapChangeFrequency.Daily
        };
        listOfUrls.Add(pageUrl);

    }
    return listOfUrls;
}

Then you will need to register that, you can do it with the .DNN file

https://github.com/ChrisHammond/dnnsimplearticle/blob/6d5d2c5bb074dd2bdede40fac4eb3c78408ab884/dnnsimplearticle.dnn

<component type="Config">
  <config>
    <configFile>web.config</configFile>
    <install>
      <configuration>
        <nodes>
          <node path="/configuration/dotnetnuke/sitemap/providers" action="update" key="name" collision="overwrite">
             <add name="DNNSimpleArticleSiteMapProvider" type="Christoc.Modules.dnnsimplearticle.Providers.Sitemap.Sitemap, DNNSimpleArticle" providerPath="~\DesktopModules\dnnsimplearticle\Providers\Sitemap\" />
          </node>
        </nodes>
      </configuration>
    </install>
    <uninstall>
      <configuration>
        <nodes />
      </configuration>
    </uninstall>
  </config>
</component>
Ad
source: stackoverflow.com
Ad