I am new to Umbraco (and Razor) and I have a question regarding the Content tree. Just below the content tree topmost node (Content), I have two child nodes. The first is the top node of the site tree and the second node is the top node of a rotator image collection.
On my home page I need to access the top node in the rotator tree. I have seen xslt code that does this but I need the Razor code. Anyone?
@{ var rotatorImageCollectionNode = 1234; <ul> @foreach (dynamic node in Model.NodeById(rotatorImageCollectionNode).Children) { <li>@node.Name</li> } </ul> }
Could also pass in the node id as a parameter, or it can be set as a property on the home page (content picker). Up to you to decide what method fits best.
Finding tree nodes in Razor
I am new to Umbraco (and Razor) and I have a question regarding the Content tree. Just below the content tree topmost node (Content), I have two child nodes. The first is the top node of the site tree and the second node is the top node of a rotator image collection.
On my home page I need to access the top node in the rotator tree. I have seen xslt code that does this but I need the Razor code. Anyone?
Hi Jon,
Here's code snippet to get you started:
Could also pass in the node id as a parameter, or it can be set as a property on the home page (content picker). Up to you to decide what method fits best.
Cheers,
/Dirk
Thanks Dirk
Great and simple solution(s).
:o)
Jon Ivar
is working on a reply...