Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Created March 2, 2012 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save warrenbuckley/1957921 to your computer and use it in GitHub Desktop.
Save warrenbuckley/1957921 to your computer and use it in GitHub Desktop.
List Child Pages From CurrentPage By Doctype
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
@* Get the content type alias we want to filter on from the macro parameter *@
var contentTypeAlias = Model.MacroParameters.contentTypeAlias;
}
@* Ensure that the rootNode has children, where the property umbracoNaviHide is not True and content type of node matches our macro param *@
@if (DynamicModel.Children.Where("umbracoNaviHide != @0", "True").Where("ContentTypeAlias == @0", contentTypeAlias).Any())
{
<ul>
@* For each child page under the root node, where the property umbracoNaviHide is not True and content type of node matches our macro param *@
@foreach (var childPage in DynamicModel.Children.Where("umbracoNaviHide != @0", "True").Where("ContentTypeAlias == @0", contentTypeAlias))
{
<li>
<a href="@childPage.Url">@childPage.Name</a>
</li>
}
</ul>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment