Skip to content

Instantly share code, notes, and snippets.

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/1710859 to your computer and use it in GitHub Desktop.
Save warrenbuckley/1710859 to your computer and use it in GitHub Desktop.
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())
{
<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>
}
}
@andersbrohall
Copy link

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