Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 16, 2013 @ 21:34
    Fuji Kusaka
    0

    Jump to nth Node

    Hi guys,

    What would be the best way of accessing a child node at a certain level instead of making use of umbracoRedirect  with the following structure

    Content
    Home
     Node 1
    -- Sub Node 1
    --- Sub Sub Node 1

    If a want Node 1 to get the url of Sub Sub Node 1 here. did try something like 

    @navi.Children.Next().First().Url
  • Rich Green 2246 posts 4008 karma points
    Apr 16, 2013 @ 22:04
    Rich Green
    0

    Hey Fuji,

    Are they all the same DocType?

    Rich

  • Rich Green 2246 posts 4008 karma points
    Apr 16, 2013 @ 22:08
    Rich Green
    0

    If not, you need to use 'Level'

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 17, 2013 @ 07:32
    Fuji Kusaka
    0

    Hi Rich,

    Yes  both -- Sub Node 1 & --Sub Sub Node 1  has the same DocType.

    @foreach(dynamic navi in Model.AncestorOrSelf(2).Descendants("DocType").Where("Level > 4")){
    @navi.Url
    }

    However here i would only need the first Url from each level 5

    @navi.First().Url not working
  • gary 385 posts 916 karma points
    Apr 18, 2013 @ 21:02
    gary
    0

    Hi Fuji

    Does .Down() work on Level?

    If so @navi.Down(2) should give you sub-sub-node. If not then .Down().Down(), but I think the (2) should work.

    Regards

    Gary

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 19, 2013 @ 12:48
    Fuji Kusaka
    0

    Hi Gary,

     

    Thanks for the reply. Tried both but aint working.

  • gary 385 posts 916 karma points
    Apr 19, 2013 @ 15:16
    gary
    0

    Hi Fuji

    Just had a play, ok, Down() gives the first child, .Down().Next() gives the second child, like you say .Down(2) gives error.

    using @CurrentPage.Down(), just for reference.

    The answer is here somewhere

    http://umbraco.com/follow-us/blog-archive/2011/3/13/umbraco-razor-feature-walkthrough-part-5.aspx

    Think it is a case of .Down(1).Down(), if not something like that.

    Regards

    Gary

Please Sign in or register to post replies

Write your reply to:

Draft