More in this section

Forums / Developing with Sitefinity / PageData querying page properties

PageData querying page properties

2 posts, 0 answered
  1. Pepperio
    Pepperio avatar
    9 posts
    Registered:
    30 Nov 2010
    15 Jun 2011
    Link to this post

    Hi, using the fluent API to get a page object:

     PageManager pageManager = PageManager.GetManager();
        PageData page = pageManager.GetPageDataList().Where(pD=> pD.Title == title).FirstOrDefault();
        return page;

    how do I then retrieve properties such as the 'show in navigation', or any of those advanced properties for that matter. Can't find them anywhere if I inspect that object.

    Also, I'm using the above by taking the SiteMapNode.Title and finding its corresponding Sitefinity page, but it seems risky as you can have many pages named the same. Is it easier to make the connection between a SiteMapNode and a Page object? SiteMapNode has a property of Key with is a Guid. but this isnt the same as the Page Guid is it?

    Thanks

  2. Tihomir
    Tihomir avatar
    23 posts
    Registered:
    09 Dec 2016
    16 Jun 2011
    Link to this post
    Hi Pepperio,

    Thank you for contacting Sitefinity Support!

    There are two important abstractions behind each Sitefinity page - 'Page Node' and 'Page Data':
    • The 'Page Data' object contains the content of the page - html, asp.net controls and etc.
    • Sitefinity uses 'Pages Nodes' for the organization - just like a hierarchical taxonomy. When a page is created, it should be attached to some 'Page Node'.

    The code below shows how to access the PageData and the PageNode objects associated with given page(via the Native API):
    var pageManager = PageManager.GetManager();
    var siteMapNode = SiteMapBase.GetActualCurrentNode();
     
    var pageNode = pageManager.GetPageNode(siteMapNode.Id);
    var pageData = pageManager.GetPageData(siteMapNode.PageId);
     
    //Check whether the page ought to be displayed in the navigation controls
    bool showInNavigation = pageNode.ShowInNavigation;

    p.s. siteMapNode.Id is the ID of the associated PageNode object and siteMapNode.PageId is the ID of the associated PageData object

    Best wishes,
    Tihomir
    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
2 posts, 0 answered