Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anton Gildebrand 49 posts 149 karma points c-trib
    Jun 14, 2013 @ 14:02
    Anton Gildebrand
    0

    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?

  • Dave Woestenborghs 3201 posts 10651 karma points MVP 4x admin c-trib
    Jun 14, 2013 @ 14:30
    Dave Woestenborghs
    0

    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

  • Anton Gildebrand 49 posts 149 karma points c-trib
    Jun 14, 2013 @ 15:01
    Anton Gildebrand
    0

    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..

  • Dave Woestenborghs 3201 posts 10651 karma points MVP 4x admin c-trib
    Jun 14, 2013 @ 15:10
    Dave Woestenborghs
    0

    Does @Current.AncestorOrSelf(1) return your top level node ?

    Dave

  • Anton Gildebrand 49 posts 149 karma points c-trib
    Jun 14, 2013 @ 17:43
    Anton Gildebrand
    0

    Yes it does indeed.

  • Dave Woestenborghs 3201 posts 10651 karma points MVP 4x admin c-trib
    Jun 17, 2013 @ 08:50
    Dave Woestenborghs
    0

    I think you need @Current.AncestorOrSelf(1).Descendants(n => n.Level == 4 && n.NodeTypeAlias == "event").Items

Please Sign in or register to post replies

Write your reply to:

Draft