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 394 posts 1477 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 1413 posts 6212 karma points MVP 3x 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 2 posts 72 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(...)
    
  • 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.

Please Sign in or register to post replies