Sub-dropdown menus?

I’m trying to port the TXT theme from HMLT5 UP to Grav. However TXT has sub-dropdown menus, something that I find very useful. In the http://saveourplanet.org/ (which uses the TXT theme as a base), I hardcoded the sub-dropdown menus in. Later on I got it a little more dynamic, but it’s still not right. I currently have it hardcoded in to only show sub-dropdowns for /about/team, since it was showing blank ones for all menu items. How would I go about properly implementing this? Here’s my current navigation.html.twig for the above site:

{% macro loop(page) %}
    {% for p in page.children.visible %}
        {% set current_page = (p.active or p.activeChild) ? 'active' : '' %}
        <li class="{{ current_page }}">
            <a href="{{ p.url }}">
                {% if p.header.icon %}<i class="fa fa-{{ p.header.icon }}"></i>{% endif %}
                {{ p.menu }}
            </a>
            {% if p.children.visible.count > 0 %}
                <ul>
                    {{ _self.loop(p) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
 {% endmacro %}
<nav id="nav">
    <ul>
        {% if theme_config.dropdown.enabled %}
            {{ _self.loop(pages) }}
        {% else %}
            {% for page in pages.children.visible %}
                {% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
                <li class="{{ current_page }}">
                    <a href="{{ page.url }}">
                        {% if page.header.icon %}<i class="fa fa-{{ page.header.icon }}"></i>{% endif %}
                        {{ page.menu }}
                    </a>
                    {% if page.header.dropdown %}
                        <ul>
                            {% for page in page.children.visible %}
                                <li>
                                  <li class="{{ current_page }}">
                                      <a href="{{ page.url }}">
                                          {% if page.header.icon %}<i class="fa fa-{{ page.header.icon }}"></i>{% endif %}
                                          {{ page.menu }}
                                      </a>
                                      {% if page == page.find('/about/team') %}
                                          <ul>
                                              {% for page in page.children.visible %}
                                                  <li>
                                                    <li class="{{ current_page }}">
                                                        <a href="{{ page.url }}">
                                                            {% if page.header.icon %}<i class="fa fa-{{ page.header.icon }}"></i>{% endif %}
                                                            {{ page.menu }}
                                                        </a>
                                                    </li>
                                                  </li>
                                              {% endfor %}
                                          </ul>
                                      {% endif %}
                                  </li>
                                </li>
                            {% endfor %}
                        </ul>
                    {% endif %}
                </li>
            {% endfor %}
        {% endif %}
        {% for mitem in site.menu %}
            <li>
                <a href="{{ mitem.url }}">
                    {% if mitem.icon %}<i class="fa fa-{{ mitem.icon }}"></i>{% endif %}
                    {{ mitem.text }}
                </a>
            </li>
        {% endfor %}
    </ul>
</nav>
---

I’m a bit confused with your code. The macro should recurse through all your pages and display the menu as a nested list. However, you seem to have manually hardcoded the same sort of thing below?

Whey don’t you a) set the dropdown: enabled: true flag in your theme, so it will use the top bit. or b) remove the check and force it to use the macro.

You may need to adjust the html output in the macro to match your required output.

OK, so I tried using the antimatter navigation code instead, and put dropdown: enabled: true in the site.config, blueprints.yaml, and txt.yaml, but there aren’t any dropdowns. What am I missing?

I was giving the shorthand syntax. Please don’t randomly put this in various places. There is only one place to put it: user/config/themes/yourtheme.yaml whatever your theme is called. Syntax is as outlined in the antimatter README.md: https://github.com/getgrav/grav-theme-antimatter:

dropdown:
  enabled: true

Sorry, I noticed about theme config after I posted. OK. I tried that, and it didn’t fix the problem. What’s my next course of action? Are there any other files that make the dropdown work besides navigation.html.twig and the theme config file?

In Antimatter, having

dropdown:
  enabled: true

in user/config/themes/antimatter.yaml should just work, tested now. Can you first try with Antimatter directly and then with your theme implementation?

OK, It shows drop and sub-dropdowns fine in the mobile version of Antimatter, but the desktop version isn’t showing a menu at all with my site.

Do you have a URL I can look at?

I’m uploading it to my server right now. One sec.

Here you go: http://cbasites.com/txt/

You know, I based my custom theme on Sidewalk. Maybe I should re-do it using Antimatter as a base?

If you view the page you will see that there’s nothing output in the top part of the page where teh navigation should be:

<div id="navbar">
                                                            <ul class="navigation">
            </ul>
                    <span class="panel-activation sb-toggle-left navbar-left menu-btn fa fa-bars"></span>
            </div>

However it is displayed just fine in the bottom sb-slidebar div.

So the problem is your simply not including the navigation at the top as you are at the bottom.

Isn’t the menu it supposed to be automatically generated with Antimatter? Is that something that custom page headers could be causing?

Well it is, but you clearly have done something to it. If you just install the antimatter theme from GPM and change your theme setting in system.yaml to use it, i’m sure the menu will show up fine.

Oddly enough, that’s what I did for that test I showed you.

I’m thinking the best thing to do is start over with Antimatter and rebuild the site. I obviously really messed something up. Thanks for the help!