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 →

[quark] mobile menu as the modular page menu

theme

Solved by Vadym View solution

Started by Bruno 4 years ago · 6 replies · 1510 views
4 years ago

Hello,
I have a one page modular site and I would like to have the modular menu with mobile or tablet.
At the moment, the mobile menu is empty (only one modular page on my site). I have made an hinerited them from quark. Is there any way to force the mobile.menu to liste the module.menu advises ?
Here is my page : http://bruno-servirlhumanite.fr
Thanks for the help.

4 years ago Solution

try this
in your inheritance theme in templates folder
create a folder named partials (if it doesn't already exists)
then copy from Quark file navigation.html.twig
and replace code with

TWIG
<ul {{ tree ? 'class="tree"' : '' }}>
    {% if show_onpage_menu %}
        {% script at 'bottom' %}
            $('.overlay-menu a').click(function () {
                $('#toggle').toggleClass('active');
                $('#overlay').toggleClass('open');
                $('body').toggleClass('mobile-nav-open');
            });
        {% endscript %}
        {% for module in page.collection() if module.header.visible is not same as(false) %}
            {% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
            <li><a class="{{ current_module }}" href="#{{ module.menu|hyphenize }}">{{ module.menu }}</a></li>
        {% endfor %}
        {% for mitem in site.menu %}
            <li>
                <a {% if mitem.class %}class="{{ mitem.class }}"{% endif %} href="{{ mitem.url }}">
                    {% if mitem.icon %}<i class="fa fa-{{ mitem.icon }}"></i>{% endif %}
                    {{ mitem.text }}
                </a>
            </li>
        {% endfor %}
    {% else %}
        {% import 'macros/macros.html.twig' as macros %}
        {{ macros.nav_loop(pages) }}
    {% endif %}
</ul>
👍 1
4 years ago

@b.da Thanks a lot, that is exactly what I was looking for. I kept the first ligne of the navigation.html.twig file and copy the code you gave me and... that's all!
I am happy with it. Best regards.

3 weeks ago

@idna same steps as in previous solution

TWIG
{# templates/partials/navigation.html.twig #}
{% import 'macros/macros.html.twig' as macros %}

<ul {{ tree ? 'class="tree navigation"' : 'class="navigation"' }}>
{% if show_onpage_menu %}
  {% for module in page.collection()|filter(module => module.header.visible is not same as(false)) %}
    {% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
    <li><a class="{{ current_module }}" href="#{{ module.menu|hyphenize }}">{{ module.menu }}</a></li>
  {% endfor %}
  {% for mitem in site.menu %}
    <li>
      <a {% if mitem.class %}class="{{ mitem.class }}"{% endif %} href="{{ mitem.url }}">
        {% if mitem.icon %}<i class="{{ mitem.icon|fa_icon }}" aria-hidden="true"></i>{% endif %}
        {{ mitem.text }}
      </a>
    </li>
  {% endfor %}
{% else %}
  {{ macros.nav_loop(pages) }}
{% endif %}
</ul>

Let's see if this functionality is popular, we can create a commit with more suitable approach to include this in theme options.

3 weeks ago

Great! Thanks! I don't think we're the only ones who miss this option in the original versions of Quark and Quark 2.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by MarkP, 2 weeks ago
3 167 1 week ago
Themes & Styling · by TomW, 2 weeks ago
0 98 2 weeks ago
Themes & Styling · by themetman, 3 weeks ago
1 192 2 weeks ago
Themes & Styling · by AH, 1 month ago
1 313 3 weeks ago
Themes & Styling · by TomW, 1 month ago
2 329 3 weeks ago