Copied to clipboard

Flag this post as spam?

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


  • Michael Hyldsgaard 64 posts 124 karma points
    May 22, 2012 @ 21:42
    Michael Hyldsgaard
    0

    Show nodes at specific level

    I'm trying to create a navigation razor script that will show all children to the current page. No problem there... but if I'm at a node that is on level 3 (or above) I have to show the the children of the parent level 2 node.

    Is this possible?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 22, 2012 @ 22:47
    Tom Fulton
    0

    Hi,

    You can do something like this:

      var startNode = Model.AncestorOrSelf(2); // Get the current node if it's level 2, otherwise walk up and get the first level 2 node

      foreach (var node in startNode.Children) {
         <li><a href="@node.url">@node.Name</a></li>
       }

    HTH,
    Tom 

  • Michael Hyldsgaard 64 posts 124 karma points
    May 23, 2012 @ 06:56
    Michael Hyldsgaard
    0

    That worked just perfectly! Thanks alot Tom... must have been tired last night... :o)

    /Michael

  • 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