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 Guys,
I very new to razor and actually loving it. I have some issues with a very simple navigation.
<ul id="navi"> @{ var naviNode = Model.NodeById(1111); var groupNode = Model.AncestorOrSelf(1); const string selectedClass = " class=\"current\""; bool hasSubNav = true; } <li><a href="/">Home</a></li> @foreach(var page in naviNode.Children.Where("Visible")) { <li@Library.If(page.IsAncestorOrSelf(Model), selectedClass)> <a href="@page.Url" title="@page.Name">@page.Name</a> </li> }</ul>
Everything is working as expected but somehow i would also like the Home link inherit the class selected whenever am on the root node.
//fuji
For some of you who might be looking for something like that in razor, here is the solution. Very simple though.
@inherits umbraco.MacroEngines.DynamicNodeContext@using umbraco.MacroEngines;<ul id="group-navi"> @{ var terraNode = Model.NodeById(1111); var groupNode = Model.AncestorOrSelf(1); const string selectedClass = " class=\"current\""; bool hasSubNav = true; <li@Library.If(Model.NodeTypeAlias == "Group", selectedClass)><a href="/">@groupNode.Name</a></li> foreach(var page in terraNode.Children.Where("Visible")) { <li@Library.If(page.IsAncestorOrSelf(Model), selectedClass)> <a href="@page.Url" title="@page.Name">@page.Name</a> </li> } } </ul>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get top level hightlighted
Hi Guys,
I very new to razor and actually loving it. I have some issues with a very simple navigation.
Everything is working as expected but somehow i would also like the Home link inherit the class selected whenever am on the root node.
//fuji
For some of you who might be looking for something like that in razor, here is the solution. Very simple though.
//fuji
is working on a reply...