summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Carver2018-12-03 16:37:03 (GMT)
committerMark Carver2018-12-03 16:37:03 (GMT)
commit6f968b866d849fa6ea3ddc8a9ddd84b6aac55656 (patch)
treeae88234d37bd4f7cf00e8241413d8ae05a70e2bf
parentbb1ce75781637c20da529d356ba325b317bfed89 (diff)
Issue #3017388 by markcarver, lonalore, erlendsl: Missing data-drupal-link-system-path from menu links
-rw-r--r--templates/menu/menu.html.twig21
1 files changed, 12 insertions, 9 deletions
diff --git a/templates/menu/menu.html.twig b/templates/menu/menu.html.twig
index 3ded5ec..0b94a21 100644
--- a/templates/menu/menu.html.twig
+++ b/templates/menu/menu.html.twig
@@ -27,20 +27,23 @@
{%
set item_classes = [
item.is_expanded and item.below ? 'expanded dropdown',
- item.in_active_trail ? 'active-trail',
+ item.in_active_trail ? 'active active-trail',
loop.first ? 'first',
loop.last ? 'last',
]
%}
<li{{ item.attributes.addClass(item_classes) }}>
- {% if menu_level == 0 and item.is_expanded and item.below %}
- <a{{ item.link_attributes.addClass(['dropdown-toggle', item.in_active_trail ? 'active-trail']) | without('data-toggle') }} href="{{ item.url }}" data-toggle="dropdown">{{ item.title }}<span class="caret"></span></a>
- {% else %}
- <a{{ item.link_attributes.addClass(item.in_active_trail ? 'active-trail') }} href="{{ item.url }}">{{ item.title }}</a>
- {% endif %}
- {% if item.below %}
- {{ _self.menu_links(item.below, attributes.removeClass(classes), menu_level + 1, classes) }}
- {% endif %}
+ {% set link_title = item.title %}
+ {% set link_attributes = item.link_attributes %}
+ {% if menu_level == 0 and item.is_expanded and item.below %}
+ {% set link_title %}{{ link_title }} <span class="caret"></span>{% endset %}
+ {% set link_attributes = link_attributes.addClass('dropdown-toggle').setAttribute('data-toggle', 'dropdown') %}
+ {% endif %}
+ {# Must use link() here so it triggers hook_link_alter(). #}
+ {{ link(link_title, item.url, link_attributes.addClass(item.in_active_trail ? 'active-trail')) }}
+ {% if item.below %}
+ {{ _self.menu_links(item.below, attributes.removeClass(classes), menu_level + 1, classes) }}
+ {% endif %}
</li>
{% endfor %}
</ul>