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

Forums / Designing with Sitefinity / How to show a page's grand-parent page?

How to show a page's grand-parent page?

4 posts, 0 answered
  1. Tim
    Tim avatar
    6 posts
    Registered:
    28 Oct 2008
    25 Jun 2009
    Link to this post
    As part of the site's page structure, I want to include a header on the page that shows the name of the page's grand-parent.

    Any suggestions on how to do that?

    Thanks.
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    25 Jun 2009
    Link to this post
    Hello Tim,

    Here is a code I quickly wrote to show you the concept of the Sitemap and its nodes, as well as Sitefinity page structure:
            CmsSiteMapNode siteNode = (CmsSiteMapNode)SiteMap.Provider.CurrentNode; 
            foreach (CmsSiteMapNode childNode in siteNode.ChildNodes) 
            { 
                if (childNode.CmsPage.ParentID != null
                { 
                    CmsManager manager = new CmsManager(); 
                    IPage parentPage = manager.GetPage(childNode.CmsPage.ParentID); 
                    Response.Write("My parent is :" + parentPage.Name); 
                    break
                } 
            } 

    The code is showing the parent page of the page. The same way you can take the parent of the parent. You can also use recursion and limit it to the level of depth you want.

    I hope this helps.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Ryan
    Ryan avatar
    5 posts
    Registered:
    23 May 2011
    06 Jul 2011
    Link to this post
    Georgi,
    I am trying to achieve the same thing-  can you let me know where to put this code to make it work?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Jul 2011
    Link to this post
    Hi Ryan,

    You can put it inside Page_Load of your control.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered