Copied to clipboard

Flag this post as spam?

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


  • Lee Fear 7 posts 97 karma points
    Nov 10, 2019 @ 19:47
    Lee Fear
    0

    Get selection of document list items for homepage

    I have followed the article - https://our.umbraco.com/documentation/tutorials/creating-basic-site/articles-parent-and-article-items/

    This gets me a list of article items for a particular article parent. However if I had a number of article items under various article parents (eg news items, features etc) How would I get the last 5 of any of those items for the homepage?

  • Anon 29 posts 125 karma points
    Nov 11, 2019 @ 19:50
    Anon
    0

    Instead of obtaining nodes by ID and getting the children, you can obtain all nodes based on what document type it is. I haven't tested it fully, but it wil be something similar to:

        var articles = Umbraco.ContentByXPath("//articlesItem")
        .Where(x => x.IsVisible())
        .OrderByDescending(x => x.CreateDate)
        .Take(5);
    

    Despite all the article nodes being different parents, as long as they have the same Document Type then this will work

Please Sign in or register to post replies

Write your reply to:

Draft