Umbraco Razor Sort Nodes Ascending or Descending

Descending:


@inherits umbraco.MacroEngines.DynamicNodeContext  
@using umbraco.cms.businesslogic.template;

@foreach(var item in Model.Children.OrderBy("Name descending"))
{
    if(item.HasAccess())
    {
        @item.Name 
    }
}


Ascending:


@inherits umbraco.MacroEngines.DynamicNodeContext  
@using umbraco.cms.businesslogic.template;

@foreach(var item in Model.Children.OrderBy("Name"))
{
    if(item.HasAccess())
    {
        @item.Name 
    }
}




Comments

Popular posts from this blog

Umbraco 7 - C# Razor - Passing a parameter variable from a Template to a Partial View.

Umbraco - Reset the Admin Password via SQL Server