Copied to clipboard

Flag this post as spam?

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


  • Mads Sørensen 188 posts 433 karma points
    Aug 28, 2014 @ 15:48
    Mads Sørensen
    0

    OrderBy multiple parameters

    Hi Guys

    I got a liste there should be listed out by descending BUT, all nodes with the properti nrOne set to "true" should be listed out before every other nodes.

    I thought I could solve it by doing like this OrderBy("nrOne,SortOrder descending". But it dosent work :P


    @foreach (var group in Model.Content.Children.Where("Visible").OrderBy("nrOne,SortOrder descending").InGroupsOf(2))
        {
            <div class="imagesContainer">  
                <div class="row">
                    @foreach (var node in group) 
                    { 
                        <a class="item" href="@node.Url">
    
                            @if(node.HasValue("vlgeImageThumb")){
                                var mediaItem = Umbraco.TypedMedia(node.GetPropertyValue("vlgeImageThumb")); 
    
                                <div class="imageThumb">    
                                    <img src="@CropUp.GetUrl(mediaItem.Url, new ImageSizeArguments{CropAlias = "pressebilledethumb"})" alt="@mediaItem.Name" title="@mediaItem.Name" /> 
                                </div>
                            } 
    
                            <span>@node.Name</span>
    
                        </a>
                    }
                </div>
            </div>
        }

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Aug 28, 2014 @ 16:35
    Dennis Aaen
    0

    Hi Mads,

    I was thinking if you could so something like this:

    Model.Content.Children.Where("Visible").OrderBy(x => x.GetPropertyValue<bool>("nrOne")).ThenBy(x => x.SortOrder); 

    I found my inspiration from this post.

    http://our.umbraco.org/forum/developers/razor/44053-Order-Blogs-by-Datepicker-property-first,-then-createDate

    Hope this helps,

    /Dennis

  • Mads Sørensen 188 posts 433 karma points
    Aug 28, 2014 @ 16:50
    Mads Sørensen
    0

    I almost se the point in the script - but it just throws me an error on the foreach right under :P

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 29, 2014 @ 11:12
    Jeavon Leopold
    0

    Dennis's suggestion looks good to me, could you try exactly like this?

    @foreach (var group in Model.Content.Children.Where("Visible").OrderBy(x => x.GetPropertyValue<bool>("nrOne")).ThenBy(x => x.SortOrder).InGroupsOf(2))
    

    If you have any error could you please post the full error here?

Please Sign in or register to post replies

Write your reply to:

Draft