Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Created March 2, 2012 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save warrenbuckley/1957541 to your computer and use it in GitHub Desktop.
Save warrenbuckley/1957541 to your computer and use it in GitHub Desktop.
List Child pages from site root (1st level)
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
@* Walk up the tree from the current page to get the root node *@
var rootNode = DynamicModel.AncestorsOrSelf.Last();
}
@* Ensure that the rootNode has children, where the property umbracoNaviHide is not True *@
@if (rootNode.Children.Where("umbracoNaviHide != @0", "True").Any())
{
<ul>
@* For each child page under the root node, where the property umbracoNaviHide is not True *@
@foreach(var childPage in rootNode.Children.Where("umbracoNaviHide != @0", "True"))
{
<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