@{ var r = new Random(); var numberOfItems = 1; var root = Model.AncestorOrSelf("Level4"); var tip = root.DocType3.First(); List<DynamicNode> pages = new DynamicNode(tip.Id).Descendants().Items.Where(x => x.Visible).OrderBy(x => r.Next()).Take(numberOfItems).ToList(); }
Brilliant, also we now have XPath as a option for getting collections when using Mvc as some new methods such as Umbraco.TypedContentAtXPath were introduced in v6.1 so it's worth thinking about.
Help Selecting all these nodes with Razor
Here is my content tree at the moment:
Content
- Level 1
- - Level 2
- - - Level 3
- - - - Level 4
- - - - Level 4
- - - Level 3
- - - - Level 4
- - - - Level 4
I am wanting to select data from all the Level 4 nodes (they are the same Doctype) and have been getting confused :)
This is where I am at the moment, which selects the first set only - how do I get all of them?
Hi Tizer,
I would use the XPath method, e.g.
or if you want to be more specific and select only Level4 docs that are children of Level3 docs then:
Thanks,
Jeavon
Thanks Jeavon - works perfectly :)
Xpath is great - I really need to get up to speed with it, I always forget about it
Thanks Jeavon - works perfectly :)
Xpath is great - I really need to get up to speed with it, I always forget about it
Brilliant, also we now have XPath as a option for getting collections when using Mvc as some new methods such as Umbraco.TypedContentAtXPath were introduced in v6.1 so it's worth thinking about.
is working on a reply...