Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Navigation with different submenu layout

Started by Andreas Ender 9 years ago · 7 replies · 1802 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 Pedro M, 2 months ago
4 195 2 months ago
Themes & Styling · by Ian, 2 months ago
3 91 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 451 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 45 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 125 3 months ago