Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Sep 21, 2015 @ 14:22
    Martin
    0

    InGroupsOf - Split Number of Items

    Hi,

    Im looking for some help with my razor. I'm trying to split an unknown number of items into two groups.

    Id like to find the number of item in items and split them evenly.

    Any help would be grateful.

    martin

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
    
    @if (Model.HasValue("SmartBulletsList")){
    
        var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("SmartBulletsList");
    
    
    
        if(items.Any())
    
        {
    
            <div>
                <div class="row">
                    @foreach(var group in items.InGroupsOf(2)) {
    
                        <div class="six">
    
                            <ul class="">
    
                                @foreach(var item in group)
                                {
    
                                <li>
                                    @item.GetPropertyValue("bulletItem")
                                </li>           
                                }
    
                            </ul>
    
                        </div>
                    }
    
                </div>
            </div>
    
        }
    
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft