Copied to clipboard

Flag this post as spam?

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


  • Søren K. Madsen 1 post 71 karma points
    Aug 19, 2015 @ 08:06
    Søren K. Madsen
    0

    Getting children of multiplenodes

    I have a problem creating a foreach with children from 2 or more nodes. There are 3 sites in one solution, and i need to show news from all sites on one of them. There is no problem getting the content from one node but i can't find a solution for combining two or more nodes

  • Lars-Erik Aabech 349 posts 1100 karma points MVP 8x c-trib
    Aug 19, 2015 @ 10:37
    Lars-Erik Aabech
    0

    You can use the SelectMany LINQ method if you've already got a set of the parent nodes, or you could possibly benefit from using the TypedContentAtXPath method on the UmbracoHelper.

    For example:

    foreach(var news in setOfParents.SelectMany(parent => parent.Children))
    {
        //...
    }
    

    or

    foreach(var news in Umbraco.TypedContentAtXPath("//ParentDocType/ChildDocType"))
    {
        //...
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft