Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//PLACE IN /ResourcePackages/<YourPackage>/MVC/Views/Navigation
@model Telerik.Sitefinity.Frontend.Navigation.Mvc.Models.INavigationModel
@using Telerik.Sitefinity.Frontend.Mvc.Helpers;
@using Telerik.Sitefinity.Frontend.Navigation.Mvc.Models;
@using System.Text.RegularExpressions;
@using Telerik.Sitefinity.Modules.Pages;
@*Add scripts and stylesheets*@
@Html.Script(Url.WidgetContent("Mvc/Scripts/Navigation.js"), "bottom")
@{
var dropdownTitle = "Navigation";
var extraCss = "";
var matches = Regex.Matches(Model.CssClass, @"%[^%]+%");
if (matches.Count > 0)
{
var title = matches[0].Value.ToString();
dropdownTitle = title.Replace("%", "");
extraCss = Model.CssClass.Replace(title, "");
}
}
<ul class="nav navbar-nav @extraCss">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span> @dropdownTitle
</a>
<ul class="dropdown-menu">
@foreach (var node in Model.Nodes)
{
@RenderSubLevelsRecursive(node, "");
}
</ul>
</li>
</ul>
@*Here is specified the rendering for the sub levels*@
@helper RenderSubLevelsRecursive(NodeViewModel node, string prefix)
{
<li>
<a href="@node.Url">@node.Title</a>
</li>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.