Dynamic children pages of a dynamic page parent - getting the parent's information

I have a set of dynamic pages with a child set of dynamic pages like so:

  • Corporate Training Dynamic Pages
    -- Sub Dynamic Pages

I am getting the content of these pages within various modules using:


How do you get the context of the dynamic parent page, when loading a dynamic child page?

Thanks for your help! :)



  • Hi there - 

    You should be able to use this call:

    Agility.Web.Data.GetDynamicPageItem(string dynamicPagePath, string contentReferenceName, DataRow contentRow)

    Does that make sense?


    Comment actions Permalink
  • Hey Joel! Thanks for the help :) 
    That makes sense to use that, but how do you reference back to the parent dynamic page you would be a part of?

    So if you have something like this:


    And you have controller actions like:

    public ActionResult Header(Module_Header module){...}
    public ActionResult PageContent(Module_PageContent){...}

    I want to show the Header module content in the context of "dynamic-page-level-1", but while showing the Page content in the context of "dynamic-page-level-2" which is defined within a list as part of the content definition of the dynamic page level 1. 

    This works fine with regular pages under a dynamic page, but not with dynamic pages under a dynamic page.

    Comment actions Permalink
  • I would have thought that maybe the context of the child page would retain some reference to the parent page it was generated from?

    Comment actions Permalink
  • I just checked through the source code for this and no, we don't capture the parent in the dynamic page item itself, however, if you access the sitemap (AgilityContext.Sitemap) and traverse that to the find the page, you should see a DynamicPageItem property on the sitemap node you are looking for.

    I hope that works for you!

    Comment actions Permalink
  • Awesome thanks Joel!

    I'll look to possibly use that method as well.

    What I ended up doing was finding the reference name of the list item within all the content definition:

    var currentContext = AgilityContext.GetDynamicPageItem<T>();

    // Search through agility shared content items for reference name of field that builds sub dynamic pages
    var parentContext = new AgilityContentRepository<T>("SharedContentListRefName").Items()
    .FirstOrDefault(x => x.SubPages.ContentReferenceName == currentContext.ReferenceName);

    if (parentContext != null)
    // if parent course is not null, then this is a sub page, set global context information to parent for ActionViews
    currentContext = parentContext;

    Not sure if this is the most elegant or performat solution, but it did the trick.

    Really appreciate your help! :) Take care.

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post