Created
January 16, 2014 07:19
-
-
Save talves/8451002 to your computer and use it in GitHub Desktop.
Razor code for Multi Menu Recursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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