Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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?
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.
is working on a reply...