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

    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">
                                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" /> 

  • Dennis Aaen 4495 posts 18201 karma points admin hq c-trib
    Aug 28, 2014 @ 16:35
    Dennis Aaen

    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.,-then-createDate

    Hope this helps,


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

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

  • Jeavon Leopold 3059 posts 13464 karma points MVP 9x admin c-trib
    Aug 29, 2014 @ 11:12
    Jeavon Leopold

    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: