Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Mar 09, 2011 @ 17:21

    Best way of getting ancestor of specific level

    What's the best way of getting an ancestor of a specific level (say for a second level nav, listing all children of the second level parent) ?

    Anyone got an idea?

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Mar 09, 2011 @ 17:43
    Sebastiaan Janssen
    1

    Something like this should work:

    @Model.Ancestors().Where("Level == 2")
  • Comment author was deleted

    Mar 09, 2011 @ 18:25

    Yeah thought so but can't make it work getting an error

    Value cannot be null. Parameter name: expression

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Mar 09, 2011 @ 18:32
    Sebastiaan Janssen
    0

    weird, that works fine for me. Does @Model.Level work though? You could have a look after setting a breakpoint, maybe the stacktrace is a little more informative.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Mar 09, 2011 @ 19:37
    Niels Hartvig
    1

    Both Ancestor(s) and Descendant(s) have level/nodetype filters now so this would work:

    - @Model.AncestorOrSelf(2) (get the ancestor (or model self) at the level of 2) 

    - @Model.AncestorOrSelf("umbHomepage") is also kind of cool (translates into get the ancestor (or model self) which has the nodetype alias of 'umbHomepage')

  • Gareth Evans 140 posts 331 karma points c-trib
    Mar 13, 2011 @ 03:45
    Gareth Evans
    0

    4.7RC didn't handle property lookups (not document properties but actual getters defined on the DynamicNode) properly

    Fixed in 4.7

Please Sign in or register to post replies

Write your reply to:

Draft