Skip to content

Navigation menu #328

Answered by Smilefounder
NagarRahul asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @NagarRahul

This is a quick example to loop through the Navigation Model inside the template MVC.

@{
void RenderMenu(List<Mix.Cms.Lib.ViewModels.MixAttributeSetDatas.MenuItem> items, int level = 0)
    {
        var menuClass = level++ == 1 ? "category-mega-menu" : "";
        <ul style="height: 458px; overflow: auto;" class="@menuClass">
            @foreach (var cat in items)
            {
                var hasChildren = cat != null && cat.MenuItems.Count > 0;
                var itemClass = hasChildren ? "menu-item-has-children" : "";
                <li class="@itemClass">
                    <a href="@cat.Uri">@cat.Title</a>
                    @if (hasChildren) {

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Smilefounder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants