Hi,
I am having trouble with getting Grav's menu system to work with Bootstrap's Nav Dropdown.
Any suggestions?
Thanks in advanced
Hi,
I am having trouble with getting Grav's menu system to work with Bootstrap's Nav Dropdown.
Any suggestions?
Thanks in advanced
Thanks to the power of the Internet, I've manged to find a solution.
For those that need it in the future, add the following between your unordered list tags.
__
{% for page in pages.children.visible %}
{% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
{% if page.children.visible.count > 0 %}
<li class="dropdown {{ current_page }}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ page.menu }} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
{% set current_parent = page.active ? 'active' : '' %}
<li class="{{ current_parent }}"><a href="{{ page.url }}">{{ page.menu }}</a></li>
<li class="divider"></li>
{% for child in page.children.visible %}
{% set current_child = (child.active or child.activeChil d) ? 'active' : '' %}
<li class="{{ current_child }}"><a href="{{ child.url }}">{{ child.menu }}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="{{ current_page }}"><a href="{{ page.url }}">{{ page.menu }}</a></li>
{% endif %}
{% endfor %}
__
I think the Bootstrap plugin already has support for enabling dropdowns. It should be a theme configuration setting.
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1336 | 9 years ago | ||
| 2 | 925 | 9 years ago | ||
| 2 | 4056 | 9 years ago | ||
| 1 | 2941 | 9 years ago | ||
| 3 | 1112 | 9 years ago |