1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Gabes sitemap control (Extended)

Gabes sitemap control (Extended)

5 posts, 0 answered
  1. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    05 Aug 2009
    Link to this post
    I found this great article by gabe (http://www.goondocks.com/blog/08-04-04/Creating_a_Site_Map_UserControl_in_Sitefinity.aspx) and it works great.

    But i want all pages to display in the sitemap, even the pages that are set "not show in navigation"... Is there perhaps a easy way to do this?

    Duncan
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Aug 2009
    Link to this post
    Hi Duncan Evans,

    The easiest way is to overwrite the dafault sitemap provider, to include non navigable pages as well:
    using System; 
    using System.Collections.Generic; 
    using System.Web; 
    using Telerik.Cms.Web; 
     
    public class CustomCmsSiteMapProvider : CmsSiteMapProvider 
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode parentNode) 
        { 
            if (parentNode == null
            { 
                throw new ArgumentNullException("node"); 
            } 
     
            IList<SiteMapNode> childNodes = BuildChildNodes(parentNode); 
            if (childNodes == null || childNodes.Count == 0) 
            { 
                return SiteMapNodeCollection.ReadOnly(new SiteMapNodeCollection()); 
            } 
     
            HttpContext context = HttpContext.Current; 
            SiteMapNodeCollection resultNodes = new SiteMapNodeCollection(childNodes.Count); 
            foreach (SiteMapNode node in childNodes) 
            { 
                // disable hiding non-navigable pages 
                //if (node is CmsSiteMapNode && !((CmsSiteMapNode)node).Navigable) 
                //    continue; 
     
                if (node.IsAccessibleToUser(HttpContext.Current)) 
                { 
                    resultNodes.Add(node); 
                } 
            } 
            return SiteMapNodeCollection.ReadOnly(resultNodes); 
        } 
     

    and register it in the web.config:
       <siteMap defaultProvider="CmsSiteMapProvider" enabled="true"
          <providers> 
            <clear/> 
            <add name="CmsSiteMapProvider" description="Displays Cms Pages"  
             type="CustomCmsSiteMapProvider, App_Code"/> 
          </providers> 
        </siteMap> 

    If you want to have this functionality specific for a control only, I am afraid that you should get all pages with the CmsManager, and build a sitemap with them from the scratch.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. David Pearson
    David Pearson avatar
    54 posts
    Registered:
    17 Jul 2012
    29 Apr 2010
    Link to this post
    Hi Georgi or anyone else who can make a recommendation,

        I was looking through the forums, and I think answer my be related to my question.  I create a sitemap.xml page generator using Roger West Creative code.  I took his ideal and added to it to include a product catalog.  That is working great for the indexing the site with the exception of news articles.  We have our Press Releases set up on a page where the news details appears on the same page.  The create sitemap code is not picking up the full news articles (/news_media/press_releases/10-02-15/Anderson_Innovation_Does_It_Again.aspx), it is only picking up the Press_Releases.aspx.

    Here is the code for indexing pages in SiteFinity. 
    foreach (Telerik.Cms.ICmsPage page in pages)
    {
        if (page.PageType != Telerik.Cms.CmsPageType.Group && page.Status == Telerik.Cms.PageStatus.Published && (page.DenyAnonymous == false) && (page.DenyIndexing == false))
        {
            WritePage(url, writer, page);
        }
    }

    Do I need to set a results page to display the full news article in order for them to be index?  Or do I need change something above?

    Thanks,
    David
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Apr 2010
    Link to this post
    Hi David Pearson,

    News detail pages are generated on the fly - they are not pages from the sitemap. This means that you can not achieve what you need with the CmsManager. You can use the News Manager API to get content items from the news module and then each content item, has an UrlWithExtension property which will give you the path to this item:
    NewsManager newsManager = new NewsManager("News");
    IList contentItems = newsManager.Content.GetContent();
    foreach (IContent item in contentItems)
    {
        string url = item.UrlWithExtension;
    }

    You can then append this path to the path of your details page to get the url for a particular news item.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. David Pearson
    David Pearson avatar
    54 posts
    Registered:
    17 Jul 2012
    29 Apr 2010
    Link to this post
    Cool Radoslav,

       Thanks for the insight.  I will add another method with that code to include those URLs.

    David
Register for webinar
5 posts, 0 answered