Files
Umbraco-CMS/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml
2015-01-15 10:38:07 +01:00

27 lines
879 B
Plaintext

@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 = CurrentPage.Children.Where("Visible").OrderBy(propertyAlias);
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}