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
Hello,
i am creating a simple Macro using razor that should list all nodes where level = 4 and content-type = event. How can i query Umbraco for this data, using Razor?
You can do something like this:
@Current.AncestorOrSelf(1).Descendants(n => n.Level == 4 && n.NodeTypeAlias == "event")
AncestorOrSelf(1) will give you the top most node in your content structure. Then you get all the descendants on level 4 with doctype even
Dave
I tried to do that now, but it doesn't find any nodes at all. It should return 2 nodes. I also tried this:
Model.AncestorOrSelf(1).Descentants()
Which i assume should list ALL of the nodes, even the ones im not interested in, but still nothing..
Does @Current.AncestorOrSelf(1) return your top level node ?
Yes it does indeed.
I think you need @Current.AncestorOrSelf(1).Descendants(n => n.Level == 4 && n.NodeTypeAlias == "event").Items
is working on a reply...
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.
Continue discussion
Find all nodes with specific level and content type
Hello,
i am creating a simple Macro using razor that should list all nodes where level = 4 and content-type = event. How can i query Umbraco for this data, using Razor?
You can do something like this:
@Current.AncestorOrSelf(1).Descendants(n => n.Level == 4 && n.NodeTypeAlias == "event")
AncestorOrSelf(1) will give you the top most node in your content structure. Then you get all the descendants on level 4 with doctype even
Dave
I tried to do that now, but it doesn't find any nodes at all. It should return 2 nodes. I also tried this:
Model.AncestorOrSelf(1).Descentants()
Which i assume should list ALL of the nodes, even the ones im not interested in, but still nothing..
Does @Current.AncestorOrSelf(1) return your top level node ?
Dave
Yes it does indeed.
I think you need @Current.AncestorOrSelf(1).Descendants(n => n.Level == 4 && n.NodeTypeAlias == "event").Items
is working on a reply...
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.