Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Item links of a single Drupal menu, in adjacent columns, using Bootstrap.
{# for a generic answer to this problem, see:
http://stackoverflow.com/questions/19836567/bootstrap-3-multi-column-within-a-single-ul-not-floating-properly
Note that this example has been tailored to a single level menu of plain links; modify a copy of the core
menu.html.twig with the changes below to keep your menu as per core.
#}
{{ menus.menu_links(items, attributes, 0) }}
{% if items %}
{%
set menu_classes = [
'list-unstyled row',
]
%}
<ul{{ attributes.addClass('menu', 'nav').addClass(menu_classes) }}>
{% for item in items %}
{%
set item_classes = [
item.in_active_trail ? 'active',
'col-xs-6',
]
%}
<li{{ item.attributes.addClass(item_classes) }}>
{{ link(item.title, item.url) }}
</li>
{% endfor %}
</ul>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.