studioespresso / craft-navigate

Navigate makes adding and maintaining menu's and navigations a breeze. Set what types of links a menu may contain, make multi-level navigations, built-in active-state check, custom classes per item.
https://plugins.craftcms.com/navigate
Other
26 stars 7 forks source link

Bug in code #65

Closed robinbraibant closed 1 year ago

robinbraibant commented 2 years ago

There is a bug in the code when a project has multiple sitegroups but the plugin only has to use one sitegroup. In the _templates/_includes/_sites.twig file you end up in the else on line 7. In the for loop, no sitegroups will be added to the the array sitegroups, due the following code:

https://github.com/studioespresso/craft3-navigate/blob/af2e0711d83776647e86f89268069ec4e9efc3ff/src/templates/_includes/_sites.twig#L11

You need to add the group object to the array in order to get correct group in the following for loop. {% set siteGroups = [] %} {% for group in craft.app.sites.getAllGroups() if group.id in navigation.enabledSiteGroups|json_decode %} {% set siteGroups = siteGroups|merge([group]) %} {% endfor %}

Using Craft: 3.7.44 Plugin version: 2.8.1

belkin commented 1 year ago

I'm experiencing same issue with multisite setup. To replicate the issue create two site groups with multisites in each group and enable the navigation to one of them. Site dropdown inside that navigation would not work.

Fix from the original reporter does indeed work.

janhenckens commented 1 year ago

Sorry this took so long to get fixed! It's now fixed for Craft 3 (in 2.9.1) and Craft 4 (in 3.1.2).