Umbraco 8 OrderBy a collection by a Custom Field Such as a Date

This is a snippet for Umbraco 8  to Order a collection by a Custom Field Such as a Date.

@{
    var selection = Umbraco.Content(Model.Id)
    .ChildrenOfType("publication")
    .Where(x => x.IsVisible())
    .OrderBy( x => x.Value("publicationDate"));
}

@foreach (var item in selection.Take(1))
{
     <h2><a href="@item.Url" title="@item.Name">@item.Name</a></h2>
}

Comments

  1. Umbraco 8 OrderBy a collection by a Custom Field Such as a Date

    Very informative post..!!

    Well, we are here to share Mobile App Development Company

    Cross Platform Mobile App Development

    Waiting for your future posts...

    ReplyDelete

Post a Comment

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco