Hi all, not sure if this has been asked before (i've looked through many forum posts but can't find anything!). I basically want to show a navigation item at level 4 but hide the item at level 3, using UmbracoNaviHide.
This is my code which is used to draw out the navigation:
@foreach (var subMenuItem in subMenuItems)
{
<ul class="col-md-3">
<li><a href="@subMenuItem.Url" title="@subMenuItem.Name" class="navigation-heading">@subMenuItem.Name</a></li>
@if (subMenuItem.Children.Where("UmbracoNaviHide == false").Any())
{
@* Call our helper to display the children *@
@SubMenuChildItems(subMenuItem.Children)
}
</ul>
}
@helper SubMenuChildItems(dynamic subMenuChildItems)
{
var childItems = subMenuChildItems.Where("UmbracoNaviHide == false");
@* Ensure that we have a collection of Sub Menu Child Items *@
if (childItems.Any())
{
<li>
<ul>
@foreach (var childItem in childItems)
{
<li>
<a href="@childItem.Url">@childItem.Name</a>
@* if the current Sub Menu Child Item has any children, where the property umbracoNaviHide is not True *@
@if (childItem.Children.Where("UmbracoNaviHide == false").Any())
{
@* Call our helper to display the children *@
@SubMenuChildItems(childItem.Children)
}
</li>
}
</ul>
</li>
}
}
@foreach (var subMenuItem in subMenuItems)
{
<ul class="col-md-3">
<li><a href="@subMenuItem.Url" title="@subMenuItem.Name" class="navigation-heading">@subMenuItem.Name</a></li>
@if (subMenuItem.Children.Where("Visible").Any())
{
@* Call our helper to display the children *@
@SubMenuChildItems(subMenuItem.Children)
}
</ul>
}
@helper SubMenuChildItems(dynamic subMenuChildItems)
{
var childItems = subMenuChildItems.Where("Visible");
@* Ensure that we have a collection of Sub Menu Child Items *@
if (childItems.Any())
{
<li>
<ul>
@foreach (var childItem in childItems)
{
<li>
<a href="@childItem.Url">@childItem.Name</a>
@* if the current Sub Menu Child Item has any children, where the property umbracoNaviHide is not True *@
@if (childItem.Children.Where("Visble").Any())
{
@* Call our helper to display the children *@
@SubMenuChildItems(childItem.Children)
}
</li>
}
</ul>
</li>
}
}
Hide level 3 show level 4 items in navigation
Hi all, not sure if this has been asked before (i've looked through many forum posts but can't find anything!). I basically want to show a navigation item at level 4 but hide the item at level 3, using UmbracoNaviHide.
This is my code which is used to draw out the navigation:
Hi Vincent,
Does it works if you do it like this instead.
Hope this helps,
/Dennis
is working on a reply...