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.

 

Automatically switch Languages & templates based on visitor ip address

Automatically switch Languages & templates based on visitor ip address

I am very beginner in joomla and need  help to use this useful extension and I was wondering if anyone knows how I can show different languages based visitors' ip addresses.
My website has two languages and two templates. (template A for es and template B for fr)  and I want the template 'A' and  language 'es' be default  and when a visitor comes to my website from Spain, website shows temp 'A' and lang 'es' and for other visitors from other countries shows template 'B' and lang 'fr'.
my links:
for es: www.mysite.com/index.php/es/
for fr: www.mysite.com/index.php/fr/

Actually I have no idea for setup my chameleon, so please give me a clear description.
Thank you very much.

fallahjeddi
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Automatically switch Languages & templates based on visitor ip address

Hi fallahjeddi,

Yes you can do this with Chameleon.

You can get an idea of some different scenarios on this page: http://www.metamodpro.com/blog/automati … la-25.html

In your case it's even easier though. For your 2 languages es and fr, just set up 2 rules in Chameleon:

Rule 1: detect the country es then in the Succeed action do 2 things: (a) set the "Language" drop-down to Spanish and (b) use the Template dropdown to set the template you want to use.

Rule 2: detect the country fr then in the Succeed action do 2 things: (a) set the "Language" drop-down to French and (b) use the Template dropdown to set the template you want to use.


There is a "gotcha" about this setup though: if the user tries to go to a different language by clicking on a language switcher, Chameleon will switch them right back to the language according to the IP address again. So to be smart about this we'll do it a little differently. Use these steps instead:

Rule 1: detect "session variable A". In the Succeed action, "Quit rule chain". In the Fail action "continue to next rule in chain". We use this to "abort" the rule chain once we have redirected for the 1st time.

Rule 2: detect the country es then in the Succeed action do 3 things: (a) set the "Language" drop-down to Spanish, (b) use the Template dropdown to set the template you want to use, (c) choose "Set Session Variable A" in the "Cookies/sess vars 1" dropdown.

Rule 3: detect the country fr then in the Succeed action do 3 things: (a) set the "Language" drop-down to French, (b) use the Template dropdown to set the template you want to use, (c) choose "Set Session Variable A" in the "Cookies/sess vars 1" dropdown.


In this way, when the system first detects the country as es or fr, it will set the language of the site and do a redirect if necessary. However if the user then uses the language switcher to go to another language, the session variable will already be set. This gets detected in Rule 1 and if its found then it won't continue to rule 2 or 3, so it won't try to redirect it again.

I trust that makes sense.

Best regards,
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
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Automatically switch Languages & templates based on visitor ip address

HI,

I just installed your SW, and it is great, I am just struggeling as newbe.

1. I want to redirect page according to GEOIP or Browser lan, I went along article https://www.metamodpro.com/forums/topic?id=2148

I does run it but the call fails, due to many redirect, since I assume the rule gets recalled

I call www.slovakia-cluster.com and then redirect to ru.slovakia-cluster.com

I read your article here, but I cannot find a way to call the laguage dropdown , I tred to add URL for rule with the www.slo-cl.com domain, so it will not run for the ru.slo-clu.com doamin, but this also does not seem to work.

I am using gtranslate,

please give me a hint

waltergrimmvie
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Automatically switch Languages & templates based on visitor ip address

Hi Walter,

Happy New Year.
Thanks for getting in touch about the redirection issues. These are classic (normal) things to solve with this sort of setup.

Ok I am not sure about all of your setup and what you are trying to achieve, but there are some things I think I can say. I hope these will help.

I assume:
- you are hosting ru.slo-clu.com, www.slovakia-cluster.com and ru.slovakia-cluster.com all on the same hosting space (they are "virtual domains" calling the same Joomla installation).

The multiple redirects are probably happening because you have a rule "if you are from russia, redirect to ru.*.com". Because www.* and ru.* are both on the same Joomla installation, the first redirect works as you expected, but then the browser calls up ru.* and AGAIN Chameleon says "are you from russia... if so, redirect". And it keeps redirecting.

So the way to avoid the loop is to include something that says "if you are already on ru.*, don't redirect".
One way to do this is to make a rule that is first in the list (may need to create a rule then re-order it to be first). In this rule, detect "is user on ru.*" and if so, in the Succeed action, "Quit rule chain".

So then you have:
Rule 1: if they are already on ru.*, do nothing and don't go to next rule
Rule 2: if they are on www.* and from GeoIP Russia, redirect to ru.*

Another way to do this, using a single rule, is to put all of these in the same rule:
- detect from GeoIP Russia
- detect on www.* domain
- Succeed action: redirect to ru.* domain

The more languages you are trying to handle, the more complex this can get, so you should try to find a solution that will scale for you.

You might also want to think about what the general rule is for redirection and domains. Some questions:
1 - Do you ever want to auto redirect people off the country-specific domains like ru.* if they are not from RU?
2 - Or, do you only want to do the auto-redirect for people who land on www.* ?
3 - Do you want to include language selection (from gtranslate or from browser language) in the criteria for redirection? There are sometimes conceptual difficulties with doing this. i.e. is it right to assume that someone from GeoIP Russia wants/needs the Russian translation? What about someone with RU as a browser language but not in Russia?

Chameleon can assist with these scenarios but it doesn't make strong assumptions about how you want this to work.

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
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Automatically switch Languages & templates based on visitor ip address

Hi,

thanxs,

I solved it with cookies in the own php section now, the tool that makes the translations supplies a var which lan was called, and using some cookies of my own I have it running.

Can  you please check my other question regarding the google search keywords to parse, is the a snippet that would show how i can get the google search keywords.

I checked your location, if you ever meet Daryl Taylor plumber from Palmerston North, i grew up with him in South Africa

thanxs

waltergrimmvie
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Automatically switch Languages & templates based on visitor ip address

Hi Walter,
Palmerston North is our next-door city but I'm afraid I don't know any plumbers there! I'll try to remember the name just in case. There are lots of South Africans here, a great bunch.

Checking your other question now.

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
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Total Posts Today:
1
User Info:
 
Total Users:
10075
Newest User:
rsker57
Members Online:
0
Guests Online:
193

Online: 
There are no members online

Forum Legend:

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