How to create a site map in sitefinity CMS?

Please give me a sample or links on how to create a site map in Sitefinity.

+3
source share
2 answers

Here you can use the Sitemap generator (free): http://enterprisefinity.com/products/sitefinity-sitemap-generator/

But you should also be familiar with some of the challenges of creating a universal Sitemap generator in Sitefinity. Each piece of content does not have a specific page where it should be displayed - it depends on the configuration of widgets on your site. Therefore, it is difficult to build a solution that understands that (for example) news from the foo department goes here, and news from the bar department goes there - Sitefinity just knows that all this is news content.

Have a look here for a better look at the code behind the Sitemap generator: http://www.sitefinity.com/blogs/joshmorales/posts/11-12-22/new_sitefinity_4_4_sdk_sample_sitemap_module.aspx

+2
source

This is how I create Sitemap content (pages, inline and dynamic) in Sitefinity 6.1.

, URL-.

  • ISite currentSite = ((MultisiteContext) SystemManager.CurrentContext).CurrentSite;
    using (var manager = PageManager.GetManager())
    {
        var nodes = manager.GetPageNodes().Where(p =>
            p.RootNodeId == currentSite.SiteMapRootNodeId &&
            p.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Standard &&
            p.ShowInNavigation);
        foreach (var node in nodes)
        {
            if (!node.Page.IsBackend &&
                node.Page.Status == ContentLifecycleStatus.Live && 
                node.Page.Visible)
            {
                string host = getPageHost(serverPort, serverName, node.Page.RequireSsl);
                var url = string.Concat(host, VirtualPathUtility.ToAbsolute(node.GetFullUrl()));
                // Then append to sitemap
            }
        }
    }
    
  • -

    using (var manager = NewsManager.GetManager())
    {
        var newsItems = manager.GetNewsItems().Where(p => 
            p.Status == ContentLifecycleStatus.Live && p.Visible).ToList();
        // append items
        foreach (var item in newItems)
        {
            var location = SystemManager.GetContentLocationService().GetItemDefaultLocation(item);
            if (location != null)
            {
                var fullUrl = location.ItemAbsoluteUrl;
                // Then append to sitemap (if page is live/visible/frontend)                    
            }
        }
    }
    
  • ISite currentSite = ((MultisiteContext) SystemManager.CurrentContext).CurrentSite;
    var providers = currentSite.GetProviders("YourModuleName").Select(p => p.ProviderName).ToList();
    foreach (string provider in providers)
    {       
        var dynamicType = TypeResolutionService.ResolveType("Fully.Qualified.Name.Of.Your.Dynamic.Type");
    
        if (dynamicType != null)
        {
            using (var manager = DynamicModuleManager.GetManager(providerName))
            {
                var dynamicTypeItems = manager.GetDataItems(dynamicType).Where(p =>
                    p.Status == ContentLifecycleStatus.Live && p.Visible).ToList();
                foreach (var item in dynamicTypeItems)
                {
                    var location = SystemManager.GetContentLocationService().GetItemDefaultLocation(item);
                    if (location != null)
                    {
                        var fullUrl = location.ItemAbsoluteUrl;
                        // Then append to sitemap (if page is live/visible/frontend)                    
                    }
                }
            }
        }
    }
    
+4

All Articles