Skip to content

Instantly share code, notes, and snippets.

@NikLP
Last active February 24, 2017 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikLP/179ce07c3a6070827cf2ac6969b767a4 to your computer and use it in GitHub Desktop.
Save NikLP/179ce07c3a6070827cf2ac6969b767a4 to your computer and use it in GitHub Desktop.
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