Details
-
Bug
-
Resolution: Fixed
-
Medium
-
4.2011
-
None
Description
I have in my site.ini, among other settings:
[SiteSettings]
DefaultAccess=en
[SiteAccessSettings]
RemoveSiteAccessIfDefaultAccess=enabled
As a result, as expected, the siteAccess is not included in the url when I surf on the default siteAccess
However when I'm on a siteaccess that is not the default one, for example fr (for french, 'en' was for english), like:
http://www.domain.com/fr/my-link
when I use the switchlanguage link to go to default siteAccess, like: http://www.domain.com/fr/switchlanguage/to/en/my-link
I'm redirected to: http://www.domain.com/en/my-link
This link is correct, but as I have RemoveSiteAccessIfDefaultAccess=enabled, the link should be:
http://www.domain.com/my-link
In order to correct the problem, I've modified the file kernel/private/classes/ezplanguageswitcher.php around line 158:
the following code:
if ( $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI ) { $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias; } else { $finalUrl = $this->baseDestinationUrl . '/' . $urlAlias; }
is replaced by:
$ini = eZINI::instance(); if ( $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI && !($ini->variable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess' ) == "enabled" && $ini->variable( 'SiteSettings', 'DefaultAccess' ) == $this->destinationSiteAccess) ) { $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias; } else { $finalUrl = $this->baseDestinationUrl . '/' . $urlAlias; }
After this patch, all redirections from switchlanguage seem to work as expected