PageNode - Difference between PageId and Id
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!
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();
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!
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