Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Navigation with different submenu layout

Started by Andreas Ender 9 years ago · 7 replies · 2234 views
9 years ago

I need a navigation with different layouts at the submenus. How can i do this:

HTML
<nav>
<ul>
<li><a href="/">Home</a></li>
<ul class="dropdown-menu">
        <li class="dropdown-submenu"><a href="#"><i class="fa fa-heart"></i>Submenu</a>
                     <ul class="dropdown-menu">
                           <li><a href="#">Menuitem</a></li>
                            <li class="dropdown-submenu"><a href="#">Menuitem with sub</a>
                                                        <ul class="dropdown-menu">
                                                            <li><a href="#">......</a></li>

At the moment i use this:

TWIG
{% macro loop(page) %}
    {% for p in page.children.visible %}
        {% if p.children.visible.count > 0 %}
            <li class="dropdown">
                <a href="{{ p.url }}">
                    {{ p.menu }}
                </a>
                <ul class="dropdown-menu">
                    {{ _self.loop(p) }}
                </ul>
            </li>
9 years ago

I think you are on the right track, basically in that check that is checking for children, you should put dropdown-submenu class on the <li> tag. Your just putting dropdown class currently.

👍 1
9 years ago

You have to edit that Twig layout you pasted above. You didn't provide the full paste of the file, so i can't really show you.

9 years ago

Here the full HTML navigation part. My problem is the twig part for the third level menu part

HTML
<nav>
    <ul>
        <li class="dropdown">
            <a href="#">First Level Menu Item</a>
            <ul class="dropdown-menu">
                <li class="dropdown-submenu">
                    <a href="#">Second Level Menu Item</a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Third Level Menu Item One</a></li>
                        <li><a href="#">Third Level Menu Item Two</a> </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</nav>
9 years ago

So, if I'm reading you right, you wish to create 3 levels deep menu?

Menu

Submenu

Sub-Submenu

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by MarkP, 2 weeks ago
3 193 2 weeks ago
Themes & Styling · by TomW, 2 weeks ago
0 111 2 weeks ago
Themes & Styling · by themetman, 3 weeks ago
1 206 3 weeks ago
Themes & Styling · by AH, 1 month ago
1 324 3 weeks ago
Themes & Styling · by Bruno, 4 years ago
6 1523 3 weeks ago