Get ancestors of page that is routed through a partial router.

Vote:
 

Hi,

I was wondering if it is possible to get all the parent pages of a page that is routed through a partial router. For example: I have a page repository right below the root page in the content tree. In a website I have a node that routes to items in the repository. Now from that page in the repository I want to retrieve all parents from the page but how it's routed through the partial router.

Something like: ContentLoader.GetAncestors(currentPage.ContentLink) but then all ancesters via the virtual route as build by the partial router.

Any suggestions?

Kind regards,

Marc

#254372
May 05, 2021 10:53
Vote:
 

Hi Marc,

Try this:

  1.  Retrieve the current content ContentLoader.GetBySegment(...)
  2.  And then use ContentLoader.GetAncestors(currentPage.ContentLink) to retrieve their ancestors.

  e.g. http://www.xyz.com/home/shop/cart 

var content =  _contentLoader.GetBySegment(currentPage.ParentLink, "cart", ContentLanguage.PreferredCulture);
var ancesstor = _contentLoader.GetAncestors(content?.ContentLink);
#254373
May 05, 2021 14:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.