[solved] Multiple domains, same site with MLE
-
- New Member
- Posts: 8
- Joined: Wed Jun 03, 2009 10:12 am
[solved] Multiple domains, same site with MLE
Hi
I am porting a multilanguage site over from a proprietary system to CMSMS MLE.
Everything is fine. The data is all uploaded for the multiple languages.
I have one issue however before I can switch over the sites.
There are multiple domains all pointing to the same space. So company.co.uk, company.de, company.eu etc etc.
In the proprietary system the programmer checks for the domain being used to access the site and then manages the correct set of language pages. Of course he can code up whatever he wants.
In CMSMS MLE I have the English site appearing as the default for all the domains at the moment, and I have the flags in the footer so I can switch between languages. But there is a flash banner with flags which link to the domain names, so the French flag goes to company.eu and the German flag to company.de. I have the CMSMS MLE install in a subdirectory so I have put an index.php file in the root which checks the domain name being used and the redirects to the CMSMS install using the following form of URL....
newsite/index.php?page=about&hl=de_DE
This correctly opens the German language version.
BUT if I use the CMSMS flags then whenever I access a menu option for the rest of that session it seems to have recorded that the language being used is the one based on the CMSMS flag.
So I am in the Dutch site, everthing is in Dutch, then I click on the link in the flash banner and go to the French domain, the index.php redirects to...
newsite/index.php?page=trial&hl=fr_FR
as required, but when I click on a menu link to go to...
newsite/index.php?page=projects
I see the Dutch version of the page again.
So I am confused about where a cookie or something is being set to show the current language. I was rather expecting that going to...
newsite/index.php?page=trial&hl=fr_FR
for instance, would fix the current language as French, for example, but obviously it isn't.
Any pointers for changing languages based on what I am trying to do would be most appreciated.
Thanks
Peter
I am porting a multilanguage site over from a proprietary system to CMSMS MLE.
Everything is fine. The data is all uploaded for the multiple languages.
I have one issue however before I can switch over the sites.
There are multiple domains all pointing to the same space. So company.co.uk, company.de, company.eu etc etc.
In the proprietary system the programmer checks for the domain being used to access the site and then manages the correct set of language pages. Of course he can code up whatever he wants.
In CMSMS MLE I have the English site appearing as the default for all the domains at the moment, and I have the flags in the footer so I can switch between languages. But there is a flash banner with flags which link to the domain names, so the French flag goes to company.eu and the German flag to company.de. I have the CMSMS MLE install in a subdirectory so I have put an index.php file in the root which checks the domain name being used and the redirects to the CMSMS install using the following form of URL....
newsite/index.php?page=about&hl=de_DE
This correctly opens the German language version.
BUT if I use the CMSMS flags then whenever I access a menu option for the rest of that session it seems to have recorded that the language being used is the one based on the CMSMS flag.
So I am in the Dutch site, everthing is in Dutch, then I click on the link in the flash banner and go to the French domain, the index.php redirects to...
newsite/index.php?page=trial&hl=fr_FR
as required, but when I click on a menu link to go to...
newsite/index.php?page=projects
I see the Dutch version of the page again.
So I am confused about where a cookie or something is being set to show the current language. I was rather expecting that going to...
newsite/index.php?page=trial&hl=fr_FR
for instance, would fix the current language as French, for example, but obviously it isn't.
Any pointers for changing languages based on what I am trying to do would be most appreciated.
Thanks
Peter
Last edited by peterfarrington on Wed May 05, 2010 7:50 pm, edited 1 time in total.
Re: Multiple domains, same site with MLE
Language is chosen in following order:
1. $_POST['hl']
2. $_GET['hl']
3. $_COOKIE['mle']
4. $_SERVER['HTTP_ACCEPT_LANGUAGE'] //visitor preferred language
5. $_SERVER['HTTP_USER_AGENT'] //visitor preferred language
6. default language from "MLE languages"
After language is chosen $_COOKIE is set for 5 hours, buts still $_GET is preferred.
Normally if links are generated by MenuManager therre should not be any link without url tail "&hl=??_??"
IMO it is not necessary to install CMSms-mle-fork to subfolder.
Just set them as aliases.
Then write UDT that checks alias on $_SERVER['HTTP_HOST'] and then sets $_GET['hl'] accordingly.
All subsequent links will be created on $config['root_url'] basis.
If problems persists - post link to page.
1. $_POST['hl']
2. $_GET['hl']
3. $_COOKIE['mle']
4. $_SERVER['HTTP_ACCEPT_LANGUAGE'] //visitor preferred language
5. $_SERVER['HTTP_USER_AGENT'] //visitor preferred language
6. default language from "MLE languages"
After language is chosen $_COOKIE is set for 5 hours, buts still $_GET is preferred.
Normally if links are generated by MenuManager therre should not be any link without url tail "&hl=??_??"
IMO it is not necessary to install CMSms-mle-fork to subfolder.
Just set them as aliases.
Then write UDT that checks alias on $_SERVER['HTTP_HOST'] and then sets $_GET['hl'] accordingly.
All subsequent links will be created on $config['root_url'] basis.
If problems persists - post link to page.
-
- New Member
- Posts: 8
- Joined: Wed Jun 03, 2009 10:12 am
Re: Multiple domains, same site with MLE
Thanks for the helpful breakdown of how the system checks language requirements.
I have not used menu_manager for this site yet as the client has a very static main menu, and the target was to get the site duplicated as quickly as possible and then work on developing the CMSMS installation.
I put the CMSMS install in a subfolder because I didn't want any possibility of messing up their live site.
There are 5 domains all pointing to the same space which actually exists on the .nl domain. If I visit the .nl domain I can switch between languages fine using the CMSMS flags. It remains completely consistent. But I need to also do something with the flag links in the flash banner - since that is part of the site design, and they are hardcoded to go to the 5 domains. So I thought I would just need to create a PHP script that redirected the browser based on the domain name.
So here are a few lines from that script...
I rather expected that visiting that address would then set the language to be en_UK for all subsequent page views. What I have found though is that although it opens the UK language home page fine, the subsequent pages are then in a different language which I guess has been picked up elsewhere.
If I redirect to the .nl domain then it seems that everything works consistently, and so this...
goes to the.nl domain and shows the en_UK home page and then continues to browse the site in English as expected (or any other variant).
So the issue I am having seems to be to do with switching the domains. The config.php is set as follows..
I wonder if this is affecting how cookies are set? And is that affecting multi-domain browsing of the site? I am happy to set a cookie in my index.php file based on the visiting domain if that would work, but I am not entirely sure where it is going wrong and what I need to do.
As I say, if I restrict the browser to the .nl domain where the CMSMS is really living then everything works OK, but if the browser is trying to view it using .co.uk. or .de, or .eu then it is (I guess) picking up a language from a cookie created previously.
If you can help at all I will be very grateful.
Peter
I have not used menu_manager for this site yet as the client has a very static main menu, and the target was to get the site duplicated as quickly as possible and then work on developing the CMSMS installation.
I put the CMSMS install in a subfolder because I didn't want any possibility of messing up their live site.
There are 5 domains all pointing to the same space which actually exists on the .nl domain. If I visit the .nl domain I can switch between languages fine using the CMSMS flags. It remains completely consistent. But I need to also do something with the flag links in the flash banner - since that is part of the site design, and they are hardcoded to go to the 5 domains. So I thought I would just need to create a PHP script that redirected the browser based on the domain name.
So here are a few lines from that script...
Code: Select all
$site = $_SERVER["HTTP_HOST"];
if($site == "www.somesite.co.uk"){
header("location: http://www.somesite.co.uk/newsite/index.php?page=trial&hl=en_UK");
}
If I redirect to the .nl domain then it seems that everything works consistently, and so this...
Code: Select all
$site = $_SERVER["HTTP_HOST"];
if($site == "www.somesite.co.uk"){
header("location: http://www.somesite.nl/newsite/index.php?page=trial&hl=en_UK");
}
So the issue I am having seems to be to do with switching the domains. The config.php is set as follows..
Code: Select all
$config['root_path'] = '/home/somesite.nl/public_html/newsite';
As I say, if I restrict the browser to the .nl domain where the CMSMS is really living then everything works OK, but if the browser is trying to view it using .co.uk. or .de, or .eu then it is (I guess) picking up a language from a cookie created previously.
If you can help at all I will be very grateful.
Peter
Re: Multiple domains, same site with MLE
Link like this...I am not entirely sure where it is going wrong and what I need to do...
Code: Select all
newsite/index.php?page=projects
If you are using links without urltail "&hl=$lang" then create UDT that saves language to $_COOKIE['mle'] every time new page is opened. E.g {save_lang}:
Call it at the very top of the page/*$params['lang']*//*mandatory*/
global $hls;
if (!empty($params['lang']) && !empty($hls) && $params['lang'] != $_COOKIE['mle']){
if ( array_key_exists($params['lang'], $hls)){
setcookie('mle', $params['lang'], time()+1800);
}
}
. (description about template processing can be found here http://forum.cmsmadesimple.org/index.ph ... #msg203281){assign var='smarty' value=$gCms->GetSmarty()}
{save_lang lang="`$smarty.get.hl`"}
Last edited by Peciura on Tue Apr 13, 2010 12:12 pm, edited 1 time in total.
-
- New Member
- Posts: 8
- Joined: Wed Jun 03, 2009 10:12 am
Re: Multiple domains, same site with MLE
Thanks very much for your help, it is much appreciated.
I have created a UDT called save_lang with the code you provided, and at the top of each template I have added the folllowing code...
I am still having a problem however. What I have noticed is that whichever of the various domains I go to, such as .eu or .co.uk, all of the URLs on the site are pointing to the domain, companyname.nl. Is this because in config.php the $config['root_url'] is set to the .nl domain?
Is the config.php page called for each CMS page view? If so, could I change the value of $config['root_url'] programatically based on the domain? I am wondering if when the browser is directed to .co.uk, for instance, a cookie may be set, but if all the links point to .nl then when he clicks on a link he ends up using the value for the language held in a cookie under the .nl domain?
I will try to change the $config['root_url'] programmatically, as well as use the code you provided. If this is wrong and you come on line before I finish, I'd appreciate a little more help.
Thanks
Peter
I have created a UDT called save_lang with the code you provided, and at the top of each template I have added the folllowing code...
Code: Select all
{assign var='smarty' value=$gCms->GetSmarty()}
{save_lang lang="`$smarty.get.hl`"}
Is the config.php page called for each CMS page view? If so, could I change the value of $config['root_url'] programatically based on the domain? I am wondering if when the browser is directed to .co.uk, for instance, a cookie may be set, but if all the links point to .nl then when he clicks on a link he ends up using the value for the language held in a cookie under the .nl domain?
I will try to change the $config['root_url'] programmatically, as well as use the code you provided. If this is wrong and you come on line before I finish, I'd appreciate a little more help.
Thanks
Peter
Re: Multiple domains, same site with MLE
YesI am still having a problem however. What I have noticed is that whichever of the various domains I go to, such as .eu or .co.uk, all of the URLs on the site are pointing to the domain, companyname.nl. Is this because in config.php the $config['root_url'] is set to the .nl domain?
I would not hack file "/config.php".
This line generally just duplicates value that is already saved in {$lang}
Code: Select all
{save_lang lang="`$smarty.get.hl`"}
-
- New Member
- Posts: 8
- Joined: Wed Jun 03, 2009 10:12 am
Re: Multiple domains, same site with MLE
Thanks for all your help.
Following your instructions I have got the multiple language - multiple domains impementation working.
Peter
Following your instructions I have got the multiple language - multiple domains impementation working.
Peter
Re: Multiple domains, same site with MLE
Welcome.
Add [Solved] to the title of your first message.
Add [Solved] to the title of your first message.
Re: Multiple domains, same site with MLE
How can I achieve this?Peciura wrote: IMO it is not necessary to install CMSms-mle-fork to subfolder.
Re: [solved] Multiple domains, same site with MLE
Creating site alias is apache stuff. Google for directives 'Virtual Host', 'ServerName' and 'ServerAlias'.
Here are links to tips how to set root url dynamically.
http://forum.cmsmadesimple.org/index.ph ... #msg214289
or even
http://forum.cmsmadesimple.org/index.ph ... 890.0.html
Here are links to tips how to set root url dynamically.
http://forum.cmsmadesimple.org/index.ph ... #msg214289
or even
http://forum.cmsmadesimple.org/index.ph ... 890.0.html
Re: [solved] Multiple domains, same site with MLE
Okay, sorry, that isn't what I'm searching for. I actually managed to setup both domains, but still there's a lang folder in my url:
englischdomain.com/en/file.html
germandomain.de/de/file.html
Is it possible to remove the lang folder?
englischdomain.com/en/file.html
germandomain.de/de/file.html
Is it possible to remove the lang folder?
Re: [solved] Multiple domains, same site with MLE
ATM there are no other means to handle languages and pretty url in CMSms-mle-fork.
There is at least one thread on building mixed urls recently posted to forum.
There is at least one thread on building mixed urls recently posted to forum.
Re: [solved] Multiple domains, same site with MLE
Hm, not the answer I wanted you to give Nevertheless, thank you.