Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1520 karma points
    Dec 06, 2019 @ 13:15
    Paul de Quant
    0

    Get All Pages by Document Type (regardless of where the page is in the site)

    Hello,

    Is it possible to get all pages (in the site) by their document type? Using Umbraco 8, I can only to this if I specify a parent page first.

        var items = Umbraco.Content(Guid.Parse("a8c3460e-667a-4c90-b237-a1c89178962a"))
                        .ChildrenOfType("dtEvent")
                        .Where(x => x.IsVisible())
    

    Thanks

    Paul

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Dec 06, 2019 @ 13:35
    Nik
    0

    Hey Paul,

    Yes you could do this, however I would probably use Examine to do it as it would be easier (in my opinion).

    You can do an examine search on the external index for everything based on it's node type alias. Then you can pass the ID's into the Umbraco.Content method to get back all the actual documents.

    Nik

  • Andrew 52 posts 234 karma points
    Dec 09, 2019 @ 18:58
    Andrew
    0

    I don't know if its the right way, but I'm using DescendantsOfType from the content at root

    Umbraco.ContentAtRoot().FirstOrDefault().DescendantsOfType(...)
    
Please Sign in or register to post replies

Write your reply to:

Draft