Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 76 posts 166 karma points
    Jan 07, 2014 @ 15:38
    Nicky Christensen
    0

    InGroupsOf doesn't work?

    Im trying to list my items in groups of 3, however, I cant get InGroupsOf() to work - If I remove Take() and InGroupsOf, then it loops, but when i have Take and InGroupsOf, then I get an error:

    @inherits umbraco.MacroEngines.DynamicNodeContext

     

     

    @if (Model.Children.Where("Visible").Any())

    {

        <div class="chapter-block">            

     

            @{

                var count = @Model.Children.Count();

            }

            @foreach (var childPage in Model.Children.Where("Visible").Take(count).InGroupsOf(3))

            {

     

                var child = childPage.Children.FirstOrDefault();

                if (child != null)

                {

                   var url = child.Url;

                   <a href="@url">

                       @childPage.chapterHeading

                   </a>

     

                }

            }

        </div>

    }

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 07, 2014 @ 16:07
    Dennis Aaen
    100

    Hi Nicky,

    Maybe this small example from Sebastiaan Janssen can help you find a solution.

    https://gist.github.com/nul800sebastiaan/1067257

    /Dennis

  • Nicky Christensen 76 posts 166 karma points
    Jan 07, 2014 @ 19:49
    Nicky Christensen
    0

    Ahhh, great, thx :) 

Please Sign in or register to post replies

Write your reply to:

Draft