Closed evertalbers closed 7 years ago
I don't have an issue with the following code (which adds the active
class to my menu item):
{% if item|current %} active{% endif %}
My menu correctly adds the active class to both menu item parent and current menu item, regardless of if I'm on /en/about-us/company-profile
, or /de/ueber-uns/unternehmensprofil
.
However, I have custom routing enabled (which may be helping this issue) - see below for an example. It also required some changes to the localeswitcher template, so that the routes are successfully changed. If you need an example, just let me know.
about-us:
path: /en/about-us/{slug}
defaults: { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'ueber', '_locale': 'en' }
contenttype: ueber
ueber:
path: /de/ueber-uns/{slug}
defaults: { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'ueber', '_locale': 'de' }
contenttype: ueber
@evertalbers Did we do any custom routing on your site when we fixed it? If so that might be the issue, cause as far as I can see the |current filter works fine for me even with the automatic routing.
Seems to work fine, closing for now. Please reopen if we run into it again.
One more thing to warn for:
{{ item|current }}
does not work when you make the slug translatable. It does work with a not-translated slug.{{ item|current }}
compares{{ item.link }}
with{{ record.link }}
I guess.