Closed andreimoment closed 2 years ago
I updated my code to the following, and the current node still does not highlight in production - while working perfectly in dev.
{% nav node in nodes %}
{% if node.active %}
{% set active_class = "-active" %}
{% else %}
{% set active_class = "" %}
{% endif %}
<li class="top-nav__item {{active_class}}">
<a href="{{node.url}}">{{node.title}}</a>
</li>
{% endnav %}
The issue with this was the site being set as sitename.com in craftcms and the host always redirecting to www.sitename.com. I added the "www." in craftcms and the menu now highlights properly. Closing.
Glad you got it sorted. I'm not sure what the "production crashes" error was (ensure you've got Show full exception views when Dev Mode is disabled
enabled in your user profile on production so you can always see a full stack trace error. But I have a feeling it's due to dump()
not being available on any environment that doesn't have devMode
enabled - so the cause of the fatal error on production.
And yep, it'll need to be exact URLs for matching, so that makes sense.
Description
This is my code. Works perfectly well in my nitro environment.
Multi-site config. The site1TopNav is nav specific to the current, default site.
Once I move to production (official domain), the highlight no longer shows.
If I uncomment the dump(active_node) line, production crashes.
Any idea on how to debug this or if there's a setting I've missed?
Steps to reproduce
Additional info
Additional context