classing the first/last item of a nav menu in razor
I'm seeing plenty of xslt-based ways of classing the last unordered list list item, but how to do so in razor? In particular, classing the razor snippet in the distro:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level);
var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass);
var parent = @Model.AncestorOrSelf(level);
if (parent != null) {
<[email protected](ulClass)>
@foreach (var item in parent.Children.Where("Visible")) {
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
<[email protected](selected)>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}
}
classing the first/last item of a nav menu in razor
I'm seeing plenty of xslt-based ways of classing the last unordered list list item, but how to do so in razor? In particular, classing the razor snippet in the distro:
Nevermind; figured it out. Changed:
to:
is working on a reply...