OliveStudio / olivemenus

A powerful menus plugin for Craft CMS built for the need of simplicity and flexibility
MIT License
40 stars 22 forks source link

Menu item active state not working correctly on all platforms. #60

Open 24HOURSMEDIA opened 1 year ago

24HOURSMEDIA commented 1 year ago

The menu active state is not working correctly on all platforms.

This is because the 'active state' is based upon the 'server name' ($_SERVER['SERVER_NAME']) which is quite different than the hostname for the request. For example, the server name may be 'phpfpm.docker.local' while the domain names may of course be different.

Changing in v4.0, in services/OlivemenusService.php

line 212

$current_active_url = Craft::$app->request->getServerName() . Craft::$app->request->getUrl();

to

$current_active_url = Craft::$app->request->getHostName() . Craft::$app->request->getUrl();

would fix this.