Link from child page to parent page

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/4/2014 2:52:02 PM
Gravatar
Total Posts 75

Link from child page to parent page

Is there a way to get the URL for the parent page from a child page when we know pageid and mid?  Please forgive me if this is in the documentation.  I am not coming up with correct search terms.  So for example, this forum post could post to https://www.mojoportal.com/forums because it is pageid=5.

4/4/2014 3:58:17 PM
Gravatar
Total Posts 1204
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Link from child page to parent page

Something like this should work:

using mojoPortal.Business;
using mojoPortal.Web;

PageSettings childPage;
PageSettings parentPage;
string childPageURL;
string parentPageURL;

childPage =  CacheHelper.GetPage(pageId); // or CacheHelper.GetCurrentPage() if running in the context of the page you want to query

string childPageURL = SiteUtils.GetPageUrl(childPage);

if (childPage.ParentId != -1)
{
   parentPage = CacheHelper.GetPage(childPage.ParentId);
   parentPageURL = SiteUtils.GetPageUrl(parentPage);
}

4/7/2014 10:19:24 AM
Gravatar
Total Posts 75

Re: Link from child page to parent page

That works like a charm.  Thanks Jamie!

You must sign in to post in the forums. This thread is closed to new posts.