Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to display a subnavigation which displays children of the current page. If there aren't any children, then I would like to display children of the parent.
Any ideas of what the Razor syntax is?
Currently using syntax below.
@inherits umbraco.MacroEngines.DynamicNodeContext@{var elementClass = String.IsNullOrEmpty(Parameter.ElementClass) ? "" : String.Format(" class=\"{0}\"", Parameter.ElementClass);var model = (@Model.Children.Count() > 0) ? @Model : @Model.Parent;}<ul @Html.Raw(elementClass)>@foreach (var item in @model.Children.Where("Visible")) {<li><a href="@item.Url">@item.Name</a></li>}</ul>
Feel free to make other suggestions. Is there a way of using AncestorsOrSelf()?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to find AncestorOrSelf with visible children?
I am trying to display a subnavigation which displays children of the current page. If there aren't any children, then I would like to display children of the parent.
Any ideas of what the Razor syntax is?
Currently using syntax below.
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var elementClass = String.IsNullOrEmpty(Parameter.ElementClass) ? "" : String.Format(" class=\"{0}\"", Parameter.ElementClass);
var model = (@Model.Children.Count() > 0) ? @Model : @Model.Parent;
}
<ul @Html.Raw(elementClass)>
@foreach (var item in @model.Children.Where("Visible")) {
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
Feel free to make other suggestions. Is there a way of using AncestorsOrSelf()?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.