Created
January 31, 2012 14:45
-
-
Save warrenbuckley/1710859 to your computer and use it in GitHub Desktop.
List Child Pages from Changeable Source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
@* Get the macro parameter and check it has a value otherwise set to empty hive Id *@ | |
var startNodeID = String.IsNullOrEmpty(Model.MacroParameters.startNodeID) ? HiveId.Empty.ToString() : Model.MacroParameters.startNodeID; | |
} | |
@* Check that startNodeID is not an empty HiveID AND also check the string is a valid HiveID *@ | |
@if (startNodeID != HiveId.Empty.ToString() && HiveId.TryParse(startNodeID).Success) | |
{ | |
@* Get the start node as a dynamic node *@ | |
var startNode = Umbraco.GetDynamicContentById(startNodeID); | |
@* Check that startNode has children pages, where the property umbracoNaviHide is not True *@ | |
if (startNode.Children.Where("umbracoNaviHide != @0", "True").Any()) | |
{ | |
<ul> | |
@* For each child page under startNode, where the property umbracoNaviHide is not True *@ | |
@foreach (var page in startNode.Children.Where("umbracoNaviHide != @0", "True")) | |
{ | |
<li><a href="@page.Url">@page.Name</a></li> | |
} | |
</ul> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the proper way to do a query like .Where("umbracoNaviHide != @0", "True") in 5.1+?