Copied to clipboard

Flag this post as spam?

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


  • Hannes Rahm 28 posts 47 karma points
    Jan 04, 2012 @ 13:42
    Hannes Rahm
    0

    Children of Child?

    Heya

    Maybe this is me beeing a complete retard, but shouldnt this work?

    @using umbraco.MacroEngines

    @inherits umbraco.MacroEngines.DynamicNodeContext

    <ul>     @foreach (var item in @Model.Children)     {

          <li>

               <a href="@item.Url">@item.Id</a>

               @foreach (var item2 in item.Children)

               {

                 @item2.ToString()<br />

               }         </li>

        } </ul>

    Should give me current pages children (works) and their respective children (doesnt work)

    I have tried a ton of variants but none work. 
    new DynamicNode(item.Id).GetChildrenAsList for example... no go.

    What is the proper way?

    /Hannes

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jan 04, 2012 @ 14:06
    Michael Latouche
    0

    Hi Hannes,

    I don't know if this will help, but I think your "foreach" should have only one "@", so like this :

    @foreach(var item in Model.Children)

    Also, have you tried with "Descendants" instead of "Children"?

    Cheers,

    Michael.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 04, 2012 @ 14:08
    Tom Fulton
    0

    Hi Hannes,

    Seems to work fine from here, what exactly is the problem?  Also not sure why you're writing @item2.ToString(), guessing just for testing?  Normally you'd be writing a property like it's name etc @item2.Name

    -Tom

  • Hannes Rahm 28 posts 47 karma points
    Jan 04, 2012 @ 15:07
    Hannes Rahm
    0

    Turns the problem was completely unrelated to razor.

    I used the Content Maintenance Dashboard to move all the child nodes.
    Looked fine in the backend, but apparently the document cache hadn't updated like it should have.

    After a republish the code worked just fine.

    Have had this problem with my own move-nodes-code before. Very annoying...

    Thanks guys!
    /Hannes 

Please Sign in or register to post replies

Write your reply to:

Draft