Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Designing with Sitefinity > How to show a page's grand-parent page?

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

  • Tim avatar

    Posted on Jun 25, 2009 (permalink)

    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.

    Reply

  • Georgi Georgi admin's avatar

    Posted on Jun 25, 2009 (permalink)

    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.

    Reply

  • Ryan avatar

    Posted on Jul 6, 2011 (permalink)

    Georgi,
    I am trying to achieve the same thing-  can you let me know where to put this code to make it work?

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Jul 7, 2011 (permalink)

    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

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Designing with Sitefinity > How to show a page's grand-parent page?