Skip to content
Create a gist now

Instantly share code, notes, and snippets.

List Child Pages from Changeable Source
@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())
@* 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>

What is the proper way to do a query like .Where("umbracoNaviHide != @0", "True") in 5.1+?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.