Umbraco Razor Simple Alternative Subnav

@inherits umbraco.MacroEngines.DynamicNodeContext



@{
 var startLevel = String.IsNullOrEmpty(Parameter.Level) ? 2 : int.Parse(Parameter.StartLevel);
 var finishLevel = String.IsNullOrEmpty(Parameter.Level) ? 8 : int.Parse(Parameter.FinishLevel);  
 var parent = Model.AncestorOrSelf(startLevel);
 if (parent != null) { @traverse(parent,startLevel,finishLevel) ; }
}



@helper traverse(dynamic parent,int startLevel,int finishLevel)
{


 foreach (var node in parent.Children.Where("Visible"))
{
 var selected = Array.IndexOf(Model.Path.Split(','), node.Id.ToString()) >= 0 ? " id=\"current\"" : "";


<li >

 <a href="@node.Url">@node.Name</a>                                      


@if (selected!=""&&@node.Level<=finishLevel) { @traverse(node,startLevel,finishLevel); }
</li>

}  


}

Comments

Popular posts from this blog

Umbraco - Reset the Admin Password via SQL Server

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version