Copied to clipboard

Flag this post as spam?

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


  • Niklas Hjelm 104 posts 125 karma points
    Oct 01, 2015 @ 15:23
    Niklas Hjelm
    0

    Foreach from multiple nodes?

    Hi, right now I'm using the following code to get items from a specific node

    @{
      dynamic node = new umbraco.MacroEngines.DynamicNode(1059);
      }
    
    <div class="articleList">
    <ul>
    @foreach (var page in node.Children.Where("Visible").OrderBy("UpdateDate desc").Take(5))
    {
    

    This works fine, but is there a way that I can have several sources combined into one list. For instance if I want to get the top 3 posts from two different nodes.

    Thanks / Niklas

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Oct 01, 2015 @ 15:39
    Jeavon Leopold
    0

    Hi Niklas,

    What version of Umbraco are you using and is this code snippet from a View (in /Views folder)?

    Jeavon

  • Niklas Hjelm 104 posts 125 karma points
    Oct 01, 2015 @ 16:29
    Niklas Hjelm
    0

    I'm using version six and the code snippet is from a macroscript (cshtml)

  • 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