Copied to clipboard

Flag this post as spam?

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


  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Dec 22, 2016 @ 11:13
    Nik
    0

    Document Type Composition/Inheritance Question

    Hey Peeps,

    Not an urgent issue or anything but I was wondering if the following was possible.

    If you are taking advantage of the amazing models builder and composition in latest versions of Umbraco, can you easily find all descendent of a node that inherit from a certain document type.

    For example,

    If you had a NewsArticleBase document type then had 2 or 3 different full News Article types, for example, ShortNewsArticle, MediaNewsArticle, DownloadNewsArticle that (for ordering purposes) were stored under repostiories.

    Could you select all decendents of "News" that inhertited from "NewsArticleBase" so you would have to go through each of the sub repostories?

    (hope that makes some sense, being honest, I've not tried anything yet as it was just an idea I'm planning on looking into)

    Thanks,

    Nik

  • Tom Steer 161 posts 596 karma points
    Dec 22, 2016 @ 11:57
    Tom Steer
    100

    Hey Nik,

    Yep you can do this using the generic IPublishedContent extension methods for example:

    https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web/PublishedContentExtensions.cs#L1769

    var newsArticles = Model.Content.Children<INewsArticleBase>();
    

    Hope this helps & Merry Christmas.

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft