Copied to clipboard

Flag this post as spam?

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


  • Mark Bro 15 posts 86 karma points
    Jan 13, 2012 @ 01:19
    Mark Bro
    0

    Creating List from a specific nodes in root using razor

    Hi,

    I am new to Umbraco and Razor and am having trouble working out how to create a list of child nodes from a specific parent using razor

    If I have the following structure

    Root - Parent1

                 - Child 1.1

                 - Child 1.2

    Root - Parent 2

                - Child 2.1

                - Child 2.2

                - Child 2.3  

    When I use

    @foreach(dynamic child in @Model.Parent.Children)
    {  @child.Name}

    it returns a list of the child nodes of the first Parent.  ie Child 1.2 & Child 1.2

    How do I force it to list the child node from Parent2?

     

     

     

     

  • alimac 177 posts 345 karma points
    Jan 13, 2012 @ 10:58
    alimac
    0

    Take a look at this: http://umbraco.com/follow-us/blog-archive/2011/2/24/umbraco-47-razor-feature-walkthrough-%E2%80%93-part-2.aspx

    @Model.NodeById() is pretty much the function you're after if you're trying to select a specific node.

  • 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