Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Jan 13, 2023 @ 00:44
    Ayo Adesina
    0

    Can you get all Published nodes that inherit from a given doc type?

    Hi guys.

    Using Umbraco V10

    I know this will give me all the nodes at the root of the content tree:

    umbracoContext.Content.GetAtRoot()
    

    Is there a way to get all child nodes that inherit from a given docType?

  • Julien Kulker 75 posts 427 karma points c-trib
    Jan 13, 2023 @ 08:00
    Julien Kulker
    102
            IPublishedContentCache contentCache = context.UmbracoContext.Content;
            var rootNodes = contentCache.GetAtRoot();
            if (rootNodes is not null && rootNodes.Any())
            {
                foreach (var node in rootNodes)
                {
                    var productPages = node.Descendants<ProductPage>().ToList();
                }
            }
    

    I think this will get you started.

Please Sign in or register to post replies

Write your reply to:

Draft