? Pending

User tests: Successful: Unsuccessful:

avatar infograf768
infograf768
27 Nov 2018

Pull Request for Issue #23144 (That issue has a wrong title)

Summary of Changes

When "Remove URL Language Code" is set to ON in the language filter plugin, the url produced for the default site language does not include the url language code.

Example on a site with fr-FR, en-GB and it-IT.
en-GB is set as default site language

Resulting urls will contain

mysite.com/ for en-GB
mysite.com/fr/ for fr-FR
mysite.com/it/ for it-IT

Before this patch, the source of the page was still showing the /en/ url language code for the part of the code concerning mod_languages flag/name link.
This has no effect on the final url but it may have some effects for crawlers as they look at all urls in a page source and therefore follow the redirect.

This patch modifies the code for the switcher in order to take off the url language code in source when necessary.

Testing Instructions

Create a multilingual site with associations.
Make sure you set "Remove URL Language Code" to ON in the Language Filter system plugin
Display frontend, hover the flag/name of the site default language in the language switcher module.
This on the home page as well as some associated pages.

Before patch

for the home (but would be similar for other pages)
switcher-before

After patch

switcher

@Giuse69

Documentation Changes Required

avatar infograf768 infograf768 - open - 27 Nov 2018
avatar infograf768 infograf768 - change - 27 Nov 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Nov 2018
Category Modules Front End
f875875 27 Nov 2018 avatar infograf768 drone
avatar infograf768 infograf768 - change - 27 Nov 2018
Labels Added: ?
avatar Giuse69
Giuse69 - comment - 29 Nov 2018

I have tested this item successfully on 81bedb7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23178.

avatar Giuse69 Giuse69 - test_item - 29 Nov 2018 - Tested successfully
avatar Giuse69
Giuse69 - comment - 30 Nov 2018

A question: why instead of re-defining setLanguagecookie() not setting it public in languagefilter? It would be better maintenable, no?

avatar infograf768
infograf768 - comment - 30 Nov 2018

There must have been a reason why it was set private in the language filter.
Anyway it uses $this which would not fit here.

avatar csthomas
csthomas - comment - 3 Dec 2018

IMO this is an easier way. Can you check.

diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php
index 7ab830b308..671d2cdcb8 100644
--- a/plugins/system/languagefilter/languagefilter.php
+++ b/plugins/system/languagefilter/languagefilter.php
@@ -224,8 +224,7 @@ class PlgSystemLanguageFilter extends JPlugin
 
                if ($this->mode_sef
                        && (!$this->params->get('remove_default_prefix', 0)
-                       || $lang !== $this->default_lang
-                       || $lang !== $this->current_lang))
+                       || $lang !== $this->default_lang))
                {
                        $uri->setPath($uri->getPath() . '/' . $sef . '/');
                }
avatar csthomas
csthomas - comment - 3 Dec 2018

Ups, my patch does not work in all cases.

avatar infograf768
infograf768 - comment - 3 Dec 2018

Ups, my patch does not work in all cases.

yep, was going to say that. ;)

avatar infograf768
infograf768 - comment - 3 Dec 2018

BTW, please also look at this other issue concerning trailing slash:
#23209 (comment)

avatar Giuse69
Giuse69 - comment - 10 Dec 2018

hi, another successful tester is needed, or.. are there doubts on the PR code?

avatar csthomas
csthomas - comment - 11 Dec 2018

I am not convinced of this solution, but I do not have time to find a better way.
@infograf768 Can you at least change in the code from public static function setLanguageCookie($languageCode) to private static function setLanguageCookie($languageCode)?

After someone finds a better way, then we can delete this method.

avatar infograf768
infograf768 - comment - 11 Dec 2018

@csthomas
Changed public to private.

avatar csthomas
csthomas - comment - 11 Dec 2018

I found a little time and created #23264.

avatar infograf768
infograf768 - comment - 12 Dec 2018

Will check today.

avatar infograf768
infograf768 - comment - 14 Dec 2018

I am closing this because the cookie may also be set when not desired.

avatar infograf768 infograf768 - change - 14 Dec 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-12-14 11:13:48
Closed_By infograf768
avatar infograf768 infograf768 - close - 14 Dec 2018

Add a Comment

Login with GitHub to post a comment