Copied to clipboard

Flag this post as spam?

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


  • suzyb 476 posts 934 karma points
    Dec 03, 2012 @ 22:08
    suzyb
    0

    Getting home node from sibling

    I just can't think how to do this tonight :(

    With the following structure, when in the template for Event Date I want to get the home node using razor so I can then build the navigation.

    Home
    -- About
    Event Container
    --- Event
    --- Event

    I was using this

    DynamicNode homeNode = @Model.AncestorOrSelf();

    but it doesn't work from an event page.  I thought the following might work however I get a "Cannot perform runtime binding on a null reference"

    DynamicNode homeNode = (DynamicNode)@Model.AncestorOrSelf(-1).Descendants("Home").First();

    I'm still trying to learn razor so don't really understand what's going on.  How do I get the home node.

  • Christian Stenfors 80 posts 124 karma points
    Dec 04, 2012 @ 10:49
    Christian Stenfors
    0

    When i first started with razor, this cheatsheet really helped

  • suzyb 476 posts 934 karma points
    Dec 04, 2012 @ 21:23
    suzyb
    0

    I worked it out.

    @Model.NodeById(-1).Home.First()

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies