More in this section

Forums / Developing with Sitefinity / PageNode - Difference between PageId and Id

PageNode - Difference between PageId and Id

4 posts, 0 answered
  1. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    27 May 2011
    Link to this post
    What is the difference between PageId and Id for a PageNode object.

    I'm asking because if I do like this:

    var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
    PageNode pgNode = pManager.GetPageNode(SiteMapBase.GetActualCurrentNode().PageId);

    I get the error: You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.

    But if I do
    var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
    PageNode pgNode = pManager.GetPageNode(SiteMapBase.GetActualCurrentNode().Id); it works

    The problem with this approach is that the ControlViewDesigner is getting through GET request PageId, Id, ParentPageId (the last one is in reality the PageId) and there is no way to get the PageNode because something like:

    PageNode pgNode = pManager.GetPageNode(new Guid(Context.Request["ParentPageId"])); will result in You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.

    (the reason is that Context.Request["ParentPageId"] is SiteMapBase.GetActualCurrentNode().PageId from the parent page)

    Therefore the question is, even if you get he parent page id in deisgner view you still cannot retrieve the pagenode (parent). Is there a solution for this?

    Thank you!
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    27 May 2011
    Link to this post
    Hi,

    The difference between Page Node ID and Page ID is that they are two completely different objects. The PageNodes also have ID's, but they are different from PageIDs. Every Page has a PageID, but PageNodes are used for the organization - just like a hierarchical taxonomies and you can consider them as a container for the Pages and PageIDs.

    You can get a PageNode by its ID, that is why your code works when you call the ID of a Page Node.

    For example if we look at this code:

    myPageNode = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).Where(p => p.Parent.Id == SiteInitializer.FrontendRootNodeId).Get().ToList();

    You will get all pages, which have FrontEndRootNode as their parent.

    I hope the above information helps you understand the differences between the PageNodeID and the PageID.

    Kind regards,
    Victor Velev
    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
  3. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    30 May 2011
    Link to this post
    Hi Victor,

    Thank you for your answer. What I still don't understand is how, based on a page Id, can I get its pagenode object.

    Basically I'm interested in getting the page node which contains a page for which I have the page id.

    Thank you!
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    30 May 2011
    Link to this post
    Hello,

    Please review the following threads which contain information and sample code about the functionality you want to achieve:

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/parent-id-of-a-page.aspx

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/pages-api-find-current-page.aspx

    Greetings,
    Victor Velev
    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
4 posts, 0 answered