Files
LeafWeb/WebCms/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml
T
2018-09-16 15:08:47 -04:00

31 lines
995 B
Plaintext

@using Umbraco.Web
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to list all child pages with a specific property, sorted by the value of that property.
How it works:
- Confirm the propertyAlias macro parameter has been passed in with a value
- Loop through all child pages that have the propertyAlias
- Display a list of link to those pages, sorted by the value of the propertyAlias
Macro Parameters To Create, for this macro to work:
Alias:propertyAlias Name:Property Alias Type:Textbox
*@
@{ var propertyAlias = Model.MacroParameters["propertyAlias"]; }
@if (propertyAlias != null)
{
var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.GetPropertyValue(propertyAlias.ToString())).ToArray();
if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}
}