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
I've seen some samples of how to accomplish this in XSLT, was wondering if anyone had a snippet for how to handle it in Razor? I just want to get a list of all nodes with a particular document type and loop through them displaying the names.
Hii Chris.
Try this :
@Model.AncestorOrSelf().Descendants("nodeTypeAlias")
Hi gilad,
Thanks for the reply!
How do I loop through the resulting nodes?
I've tried:
var productNodes = @Model.AncestorOrSelf().Descendants("Product");foreach (var productNode in productNodes){ @productNode.Name<br />}
but it's throwing an error.
Hii, sorry.
Add .Items to first line :
var productNodes =@Model.AncestorOrSelf().Descendants("Product").Items;
Is there a way to return all nodes except for a certain document type? eg.
var nodes =@Model.AncestorOrSelf().Descendants("not Product").Items;
You could eventually do something like this
var c = new DynamicNode(1024).GetChildrenAsList.Items.Where(x=>x.GetProperty("umbracoNaviHide").Value != "1" && x.NodeTypeAlias !="docType");
Hope this helps
//fuji
in 7.7.2
var names = Model.Content.AncestorOrSelf(1).Descendants("doctypealias") foreach (var name in names) { <p>@name.Id</p> <p>@name.Name</p> }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Getting All Content Nodes of Particular Document Type
I've seen some samples of how to accomplish this in XSLT, was wondering if anyone had a snippet for how to handle it in Razor? I just want to get a list of all nodes with a particular document type and loop through them displaying the names.
Hii Chris.
Try this :
@Model.AncestorOrSelf().Descendants("nodeTypeAlias")
Hi gilad,
Thanks for the reply!
How do I loop through the resulting nodes?
I've tried:
but it's throwing an error.
Hii, sorry.
Add .Items to first line :
Is there a way to return all nodes except for a certain document type? eg.
You could eventually do something like this
Hope this helps
//fuji
in 7.7.2
is working on a reply...