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 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
I tried to do that now, but it doesn't find any nodes at all. It should return 2 nodes. I also tried this:
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...
Write your reply to:
Image will be uploaded when post is submitted