Copied to clipboard

Flag this post as spam?

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


  • Joao 53 posts 172 karma points
    May 31, 2013 @ 14:48
    Joao
    0

    DynamicNodeWalker Problems

    Hello!

    I'm having trouble accessing child nodes inside a foreach. I'll start by providing the content structure:

    root

       blog

          blogpost1

             block1

             block2

             ...

          blogpost2

             block1

             block2

             ...

         ...

    I'm on the blog page and I want to display, for each blogpost, the title (property of blogpost) and the property text of the first block.

    Right now I have this, and it works:

    <umbraco:Macro runat="server" language="cshtml">
    @foreach (var item in @Model.BlogPost.Where("Visible"))
    {
         @item.blogPostTitle;
      } 
    </umbraco:Macro>

    But when I try to go further down the tree, like so:

    <umbraco:Macro runat="server" language="cshtml">
    @foreach (var item in @Model.BlogPost.Where("Visible"))
    {
         @item.blogPostTitle;

         @item.Down(2).text
      } 
    </umbraco:Macro>

    I always get the Error loading MacroEngine script (file: )

    I probably can't do the  @item.Down(2).text and I don't know how to do it properly.

    Can anyone shed some light ?

     

    Thanks

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    May 31, 2013 @ 18:26
    Jeavon Leopold
    0

    Hi Joao,

    I think you just need to go Down(1) to get to block1 as Down(2) would take you to the child of block1 which doesn't exist?

    Thanks,

    Jeavon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    May 31, 2013 @ 18:29
    Jeavon Leopold
    100

    Sorry, should be Down(0) which is to traverse one level

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 01, 2013 @ 07:30
    Fuji Kusaka
    0

    Hi Joao,

    Did you get this working ?

  • Joao 53 posts 172 karma points
    Jun 01, 2013 @ 21:24
    Joao
    0

    Yep, it worked with .Down(0)

    Thank you!

  • 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