Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Chamelon + Language domains malfunction

Chamelon + Language domains malfunction

We've bought Chameleon for our multilingual Joomla site and we're using It to show different pages based on the language and country of the visitors. The extension is a real genius, we already have ideas on how to exploit It's potential in the future.

However there is a side effect we must fix. We use the System - Language domains plugin to set subdomains for each languages. When the System - Chameleon plugin is enabled, the domain of  home page will be rewritten to show https://www.domain.com/en/ at the end, so en/ is added. When the user switches language, It will disregard the language subdomains and try to load the domain with https://www.domain.com/{languagecode}/ at the end instead of https://{languagecode}.domain.com which happens normally without the Chameleon plugin enabled. On other menu items, than the homepage swithing language works as It should and loads the subdomains of the chosen language and the language code is not being added after the domain name.

sera
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

Hi Sera,

hmm, this is interesting regarding interactions with the "System - Language domains" plugin. I haven't tried to use the two together.

When you say that the problem occurs when the Chameleon plugin is enabled, does that happen when particular Chameleon rules (or types of rules, e.g. ones that have particular actions) are active? Or does it happen even with no rules active?

To help diagnose that, you can turn on Chameleon's Debug mode (in the Options panel) and look at the output when you view pages on the front end. It would be interesting to know if any of the following scenarios trigger the problem:

1 - Chameleon enabled, but no active rules
2 - Chameleon enabled, 1 rule active that has no conditions and no actions (i.e. just create it, name it and save it)
3 - Chameleon enabled, and a rule with no conditions but an action that switches language (or any other related actions)

Second plan of attack:
The order of plugins often matters. Try ordering the system plugins so that the "System - Language domains" plugin is BEFORE the Chameleon plugins, or AFTER them. I suspect that placing it BEFORE may be helpful.

Third plan of attack:
Chameleon should be able to replace the "System - Language domains" plugin completely. i.e. you can probably achieve the same results with Chameleon alone.
e.g. set up a rule that detects language "fr" in "Only these languages", "Joomla front end language" in $language handling in Config, and domain names "en.domain.com, de.domain.com" in the Environment tab. In the Succeed Action, set Next Action to "Redirect...", and set the "Redirect url..." to "{scheme://}fr.domain.com{:port}{path}{?query}{#fragment}"

i.e. if the language is set to french but the user is on the English or German domain, send the person to the very same URL but on the French domain name.

Repeat for each of the domains. i.e. if on English language but on French or German domain, send to English domain; if on German language but English or French domain, send to German domain.

If you need to drop the leading language code off the path, e.g. take the "en/" out of the "domain.com/en/path_here" when you redirect it to "fr.domain.com/path_here", then you can change the redirect string to:

{scheme://}fr.domain.com{:port}{path_drop_1}{?query}{#fragment}

Hope that helps. If you are still having trouble with it, let me know and I can look further into the "System - Language domains plugin" to see if I can make them interoperate more.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

Hi Stephen,

First of all, thank you for your response, your support is like your extension: awesome.

I  check the plugin order, System - Language Domains is like -9000 and is loading before System - Chameleon.
Debug didn't show me any errors, or useful information.

I have a few rules setup all of them are very simple: 
- Config > Enable GeoIP/GeoCity > GeoLite2 Country
- Quick Rules > Only these countries > {some country codes}
- Enviroment > Page URL > equals > {a full URL}
- Actions > Next action > Redirect > redirect page... > {language specific menu item}

If any of these rules above are published, homepage will be loaded with "/en/" at the end, if I switch language It wont load the subdomains for languages, but add language code at the end of the domain - interestingly the redirects for language subdomains are even included in the .htacess, not sure if this would interfere.

I'd be happy to use Chameleon to control the language subdomains, that would mean I can disable/remove the System - Language Domains plugin(less extension = faster load times)
I don't need the site automatically load the language subdomains, we got a language switcher, visitors use it to switch language if they wish.

The other action what I need is loading different urls (subscriptions setup for different regions, with different currencies and prices) based on the origin country of the visitor. /premium   would redirect to   premium-us, premium-eu etc. Would be nice If I don't have to add the redirects for each language subdomains - we've 16 languages smile

I'd greatly appreciate some tips and help with the setup for the 2 things above.

Thanks in advance,
Sera

sera
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

Hi Sera,

just a quick check: have you tried placing the "System - Language Domains" so that it loads after Chameleon instead of before it?

If that doesn't work either, then I'll install "System - Language Domains" on my test machine and see what's going on. Sorry this isn't working - I can see it's such a pain.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

I tried placing the System - Chameleon plugin before System - Language Domains. Got the same results.

If I can setup rules in Chameleon to control language subdomains as I described above, I'd rather do that and remove the System - Language Domains plugin. Could you assist with this? smile
I tried turning off System - Language Domains and turned on Joomla default System - Language Filter
- Enviroment > Only these languages > "de"
- Enviroment > Domain names > www.domain.com, etc (tried Page URL > contains/starts with but didn't succeed)
- ACTIONS > Next action > redirect > {scheme://}de.manili.com{:port}{path}{?query}{#fragment}

This worked, but when I changed {path} to {path_drop_1} the page didn't load - got into a loading loop (GET /de/)
So I still need to remove the /de/ language path.

EDIT: After some testing I realized that I can't have a second redirect when the user switching language - It triggers a GET for www.domain.com/{languagecode} then another GET for {languagecode}.domain.com
I need a solution that work like the System - Language Domains plugin, or I need Chameleon to be cooperative with it smile

sera
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

Ok, I have a fix for you.
The reason for the error is complex so I won't go into it here!
I have decided not to put this fix directly into Chameleon because it can have unexpected side-effects if the Language Domains plugin is not enabled on the site.
So what you need to do (I did this on your test site) is create a new Chameleon rule that is FIRST in the list of Chameleon rules. Don't add any conditions, but in the SUCCEED ACTION PHP box enter the following:

$languageCode = JFactory::getSession()->get('plg_system_languagefilter.language');
if (strlen($languageCode) > 2) {
    JFactory::getSession()->set('plg_system_languagefilter.language', substr($languageCode,0,2));
}

then select the radio button for "Next Action: Process next rule in chain".

If you ever have to disable the Language Domains plugin, then just disable this Chameleon rule as well, and the site should work fine.

Please let me know if you have any trouble with this. I think it's going to be ok, and certainly in testing it prevents the double GET request that goes to fr.example.com/fr on the front page.

In the end I decided to retain the use of Language Domains instead of trying to recreate this with Chameleon alone. It may have been possible the other way, but there may still have been issues with the /fr language codes. As long as there are no other side-effects, I think this ends up being a good solution.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Chamelon + Language domains malfunction

Hi Stephen,

I was about to contact you through email/pm, but before that I checked the forums and saw you posted the solution here.
Thank you very much for fast and perfect fix and solution!

Once again genius! smile

sera
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11527
Newest User:
david9684
Members Online:
3
Guests Online:
171


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked