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
Hi all,
Hope we all had good Christmas,
I'm working on a simple navigation, I've got the navigation working and if any child are under it will render these in a drop down.
However what I want to do is be able to disable the dropdown even if there are child under the node.
What I've done was created a true/false and when this is set to false I want the dropdown not to display. just the node.
Here is my code;
@inherits Umbraco.Web.Mvc.UmbracoViewPage @{ var selection = Umbraco.ContentAtRoot().FirstOrDefault() .Children() .Where(x => x.IsVisible()); } <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav"> <div class="w-container"> <nav role="navigation" class="navmenu w-nav-menu"> <a href="/" class="navlink w-nav-link">Home</a> @foreach (var item in selection) { var children = item.Children(c => c.IsVisible()).ToArray(); if (children.Any()) { <div data-hover="1" data-delay="0" class="w-dropdown"> <div class="navlink w-dropdown-toggle"> <a href="@item.Url"> <div>@item.Name</div> </a> </div> <nav class="w-dropdown-list"> @foreach (var child in children) { <a class="navlink w-dropdown-link" href="@child.Url" >@child.Name</a> } </nav> </div> } else { <a href="@item.Url" class="navlink w-nav-link">@item.Name</a> } } </nav> <div class="handburger w-nav-button"> <div class="w-icon-nav-menu"></div> </div> </div> </div>
I thought I could just change this line
if (children.Any())
to
if (!item.Value<bool>("disableDropdown") && (children.Any())
But doesn't seem to be that simple.
Any help would be great.
Thanks
Changed it to this and worked;
if (!item.Value<bool>("disableDropdown") && item.Children != null && item.Children.Where(x => x.IsVisible()).Any())
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Navigation with drop down
Hi all,
Hope we all had good Christmas,
I'm working on a simple navigation, I've got the navigation working and if any child are under it will render these in a drop down.
However what I want to do is be able to disable the dropdown even if there are child under the node.
What I've done was created a true/false and when this is set to false I want the dropdown not to display. just the node.
Here is my code;
I thought I could just change this line
to
But doesn't seem to be that simple.
Any help would be great.
Thanks
Changed it to this and worked;
is working on a reply...