Hello, I have a menu which changes color depending on which node its on, still same menu and everything, and the value for CurrentModel.AncestorOrSelf(2) (when debug with breakpoints I get correct value). But I cannot get it to work, whole code (foreach) works just fine for menu (1).
public static bool IsInMyArea(DynamicNode node) { var ret = false; while (node!=null) { if (node.NodeTypeAlias == "MyNetRoot") { ret = true; break; } node = node.Parent; } return ret; }
Changing Menu from level 1 to level 2
Hello, I have a menu which changes color depending on which node its on, still same menu and everything, and the value for CurrentModel.AncestorOrSelf(2) (when debug with breakpoints I get correct value). But I cannot get it to work, whole code (foreach) works just fine for menu (1).
Macroscripts:
@{var level = 1; if (Helper.IsInMyArea(CurrentModel)) { level = 2; } }@foreach (var node in CurrentModel.AncestorOrSelf(level).ChildrenAsList.Where(p => p.GetPropertyValue("umbracoNaviHide") == "0"))
{
var menuType = node.GetPropertyValue("menuType");
if (menuType != "Main menu" && menuType != "Main menu and big") { continue; }
var css = "small"; // <a class="active"
var selected = Array.IndexOf(CurrentModel.Path.Split(','), node.Id.ToString()) >= 0 ? " class=\"active\"" : "";
if (menuType == "Main menu and big") { css = "big"; }
<a @Html.Raw(selected) href="@node.Url"><div class="left"></div><div class="item @css">@node.Name</div><div class="right"></div></a>
}
</div>
<div class="clear"></div>
And my Helper class has following
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.