PageNode to PageSiteNode

Posted by Community Admin on 04-Aug-2018 15:56

PageNode to PageSiteNode

All Replies

Posted by Community Admin on 12-Aug-2011 00:00

Here's my issue...

I'm trying to print navigation based off of PageSiteNodes instead of SiteMapNodes. Before you suggest against it, here is why:

In my code, I am using the API to find a PageNode based off of a PageId that is selected by the end-user:
App.WorkWith().Page(PageId).Get();

In my opinion, PageId is the only way you should do a search. I know I can find a PageSiteNode or SiteMapNode by searching by the Title or UrlName. I'm looking for a more exact approach. I have worked with sites where the Title and even UrlName may be the same (Same page under different sections). Anyways - I'm trying to come up with a solution to turn my PageNode into a PageSiteNode so that I can access children and parent nodes.

This is for a control in the marketplace. When providing a solution - please don't suggest that I match by Title or UrlName. The solution I'm looking for is to match by PageId - which both PageSiteNode and PageNode have.

Thanks!

Posted by Community Admin on 12-Aug-2011 00:00

you may get what you need with

PageNode pn = PageManager.GetManager().GetPageNode(new Guid(userPageId));

or
PageNode pn2 = PageManager.GetManager().GetPageData(new Guid(userPageId)).NavigationNode;
if the Id is from a PageData object... The PageNode object has a .Nodes collection of children as if you were navigating the Page Hierarchy

Posted by Community Admin on 12-Aug-2011 00:00

readonly - that is actually the opposite direction I'm looking to go.

I want to get a PageNode (or Page or PageData) from a PageSiteNode.

Posted by Community Admin on 16-Aug-2011 00:00

I needed to get the PageData so that I could pull the description (the description used to be available from the PageSiteNode itself before 4.2).  This worked for me:

PageNode pageNode = App.WorkWith().Page(pageSiteNode.Id).Get();
desc.Text = pageNode.Page.Description;

This thread is closed