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

Materialize dropdown

Started by Muut Archive 11 years ago · 8 replies · 602 views
11 years ago

Are you running the materialize theme? If so, perhaps you can submit an issue on that theme project on GitHub?

Have you looked at how the dropdown is implmemented in Antimatter theme? It's toggled from antimatter.yaml, but the logic and output is all in partials/navigation.html.twig. The styling would all be provided by the materialize css/js that the materialize framework provides.

11 years ago

No but I will submit an issue.

Yes but I think the Materialize dropdown is different and I wonder how to deal with the "Dropdown Structure" and the "Dropdown Trigger":
--- html
<p><!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider"></li>
<li><a href="#!">three</a></li>
</ul>
<nav>
<div class="nav-wrapper">
<a href="#!" class="brand-logo">Logo</a>
<ul class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<!-- Dropdown Trigger -->
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
</nav></p>

11 years ago

You would just have to edit the partials/navigation.html.twig to add the bits and pieces needed for this dropdown structure.

11 years ago

Thank you but what would you do if you had multiple dropdowns? Could you somehow make the dropdown-part dynamic, too?

11 years ago

I'm not sure i'm following. The dropdowns will be dynamic because they are built from the page structure. If you mean visually, that's totally up the CSS you use to render the dropdown.

11 years ago

Sorry for my complicated question!
How would you code the id in the "Dropdown-Structure" and the data-activates in the "Dropdown-Trigger" if you had multiple dropdowns?

11 years ago

What i would do is when you 'include' this navigation menu twig from your template, i would pass in a variable like this:

TWIG
{% include 'partials/navigation.html.twig' with {'menu_id':'dropdown1'} %}

Then in your navigation.html.twig have something like:

TWIG
<ul id="{{ menu_id }}" class="dropdown-content">
...

Then if you need another menu on your page you could put:

TWIG
{% include 'partials/navigation.html.twig' with {'menu_id':'dropdown2'} %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1338 9 years ago
Archive · by Muut Archive, 9 years ago
2 927 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago