Skip to content

Instantly share code, notes, and snippets.

@talves
Created January 16, 2014 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talves/8451002 to your computer and use it in GitHub Desktop.
Save talves/8451002 to your computer and use it in GitHub Desktop.
Razor code for Multi Menu Recursion
<div class="container">
<ul class="main-Menu">
@foreach (var item in MenuHelper.Top())
{
@ShowTree(item);
}
</ul>
</div>
@helper ShowTree(Kooboo.CMS.Sites.Models.Page item) {
if (item.Navigation.Show){
var subs = MenuHelper.Sub(item).ToList();
if (subs!=null && subs.Count>0) {
<li class="@(MenuHelper.IsCurrent(item) ? " active" : "")">
@Html.FrontHtml().PageLink(item.LinkText, item.FullName)
<ul class="sub-menu">
@{foreach (var subitem in subs){
@ShowTree(subitem);
}}
</ul>
</li>
} else {
<li class ="@(MenuHelper.IsCurrent(item) ? "active" : "")">@Html.FrontHtml().PageLink(item.LinkText, item.FullName)</li>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment