Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anthony Candaele 1197 posts 2049 karma points
    Sep 30, 2013 @ 11:05
    Anthony Candaele
    0

    subnavigation issue in v6 Razor

    Hi,

    I want to create a subnavigation macro partial for my publications

    enter image description here

    I could make it easy by this code:

    var publicationcategories = Model.Content.Children;
    

    but this wil only work on the Publications page. If on a publication category page, it will list the children nodes of that publicationcategory node, which is not what I want. I want to list the children of the Publications node, no matter where I am in the hierarchy.

    So I tried something like this:

    var categories = Model.Content.AncestorsOrSelf("PublicationArea").Children;
    

    but the Children method is not recognized as a method of AncestorsOrSelf(string NodeType Alias)

    Does anyone know how I can list the children of the Publications node, no matter where I am in the navigation hierarchy?

    Thanks for your help,

    Anthony

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Sep 30, 2013 @ 11:12
    Jeavon Leopold
    100

    Hi Anthony, just one character 's'

    Try:

    var categories = Model.Content.AncestorOrSelf("PublicationArea").Children;
    

    Jeavon

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 30, 2013 @ 11:18
    Anthony Candaele
    0

    Hi Jeavon,

    Thanks, it works! I was checking the Umbraco v6 MVC Razor Cheatsheets , there it references only the Collections method:

    .AncestorsOrSelf(string nodeTypeAlias)
    

    But

    .AncestorOrSelf("PublicationArea").Children;

    works.

    Thanks a lot,

    Anthony

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Sep 30, 2013 @ 12:11
    Jeavon Leopold
    0

    Yes, I guess it along with the other single selector methods should be in the traversing section as it is on the old DynamicNode cheatsheet :-)

Please Sign in or register to post replies

Write your reply to:

Draft