BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 37 forks source link

menu.yml / {{ item|current }} with translateable slug #79

Closed evertalbers closed 7 years ago

evertalbers commented 8 years ago

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.

lswest commented 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
SvanteRichter commented 7 years ago

@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.

SvanteRichter commented 7 years ago

Seems to work fine, closing for now. Please reopen if we run into it again.