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

The sign +In sub menu

Solved by pamtbaau View solution

Started by Dave Torchia 8 years ago · 2 replies · 629 views
8 years ago

Hi, i have another question about the submenu…always in quark theme…I attach a screenshot, I would not see the “+” sign to open the submenu, but directly click on the menu item to bring up the submenu … how can I do? thank you in advance…IMG_20180830_122109|281x500

8 years ago Solution

I don't consider the following really as a solution, but rather a hacky override of 'jquery.treemenu.js' (which runs the menu) plus some required css compensation.

  • Create inherited theme from quark-open-publishing if not already.
    Use either of the following two options:

  • Copy file '/user/themes/quark-open-publishing/templates/partials/navigation.html.twig' into folder '/user/themes/mytheme/templates/partials'

  • Change the following lines in your copy of 'navigation.html.twig'...

    TWIG
    {% if p.children.visible.count > 0 %}
     <li>
        <a href="{{ p.url }}" class="{{ active_page }}">
    

    ...into

    TWIG
    {% if p.children.visible.count > 0 %}
     <li>
        <a class="toggler {{ active_page }}">   <- only changed line
    

    Note:

    • Removing the 'href' prevents the <a> from opening the page it referred to.
    • Class 'toggler' tells 'jquery.treemenu.js' to use the <a> to open/close the submenu.
  • Add the following lines to '/user/themes/mytheme/css/custom.css':

    CSS
    .treemenu .toggler {
      display: contents;
    }
    
    .treemenu li.tree-empty > .toggler:before {
      content: initial;
    }
    
    .treemenu li {
      padding: 0;
      margin: 1rem 0;
    }
    

    Disclaimer:

  • Not tested on real mobile phone, but emulated mobile display using Chrome developer tools on Windows 10.

  • It does not work for all browsers since 'display: content' is not supported by all browsers. See Can I Use. If not supported, the layout will be horrible.

  • Not tested if multi-level submenu's work.

  • Test in your own and visitors context.

👍 1
last edited 08/31/18 by pamtbaau

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 198 2 months ago
Themes & Styling · by Ian, 2 months ago
3 94 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 456 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 48 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 128 3 months ago