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.

 

Template & language based on domain

Template & language based on domain

Hi there,

I want to have a template and language rule per domain.

We have an extended range of country specific domain names .de, .nl, co.uk, .at, .it, .com etc.

We also have 3 product groups with each a different template and each a specific domain name. We have it all on one Joomla install for easy maintenance and translation. For the translation we are using joomfish on Joomla 1.5.

How can we fully disable the language selection and give a specific fixed language per domain name? Now it seems that it still picks Dutch in my case, when I go to the English domain...

I trust this is possible, but I just cannot seem to get it working correctly.

Thanks in advance for your help.

Joris

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

Re: Template & language based on domain

Hi Joris,

I'll take a look at some possibilities for forcing the language differently on each domain name.

Are you using VirtueMart for the products? Or is it just a matter of standard article content on the site?

Could I ask if/how you are forcing different sets of content for the different domains? Is that something you need to achieve too?

Thanks for any more info,
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
3319 Posts
User info in posts
Administrator has disabled public posting

Re: Template & language based on domain

Ok, that was a lot harder than I thought it would be. There are some restrictions to what you can do with this, unfortunately, because of the way that the JFSEF plugin is coded.

Anyway, here's how to set it up:

1 - create a Chameleon rule (1 per domain).

2 - in the "Exclude these languages" enter the 2-letter code for the language that you want this domain to use, e.g. "de". Yes, it seems counter-intuitive to be "excluding" the language that you want to use for this domain, but the point is to catch any other language, and redirect it.

3 - in the "domains" box enter the full domain name of the domain you want to use for that language e.g. "mydomain.de"

4 - in the "succeed action" PHP box in the right column, copy and paste the following. Sorry it's so long:

Code:

$client_lang = 'de';


require_once( 'administrator/components/com_joomfish/tables/JFLanguage.php');
$registry = JFactory::getConfig();
$jfLang = TableJFLanguage::createByShortcode($client_lang, false);
if( $jfLang === null && $client_lang!="") {
    $jfLang = TableJFLanguage::createByISO( $client_lang, false );
}
else if( $jfLang === null) {
    $jfLang = TableJFLanguage::createByJoomla( $locale );
}

$href= "index.php";
$hrefVars = '';
$queryString = JRequest::getVar('QUERY_STRING', null ,"SERVER");
if( !empty($queryString) ) {
    $vars = explode( "&", $queryString );
    if( count($vars) > 0 && $queryString) {
        foreach ($vars as $var) {
            if( preg('/=/i', $var ) ) {
                list($key, $value) = explode( "=", $var);
                if( $key != "lang" ) {
                    if( $hrefVars != "" ) {
                        $hrefVars .= "&";
                    }
                    // ignore mosmsg to ensure it is visible in frontend
                    if( $key != 'mosmsg' ) {
                        $hrefVars .= "$key=$value";
                    }
                }
            }
        }
    }
}

// Add the existing variables
if( $hrefVars != "" ) {
    $href .= '?' .$hrefVars;
}

if( $jfLang->getLanguageCode() != null ) {
    $ulang = 'lang=' .$jfLang->getLanguageCode();
} else {
    // it's important that we add at least the basic parameter - as of the sef is adding the actual otherwise!
    $ulang = 'lang=';
}

// if there are other vars we need to add a & otherwiese ?
if( $hrefVars == '' ) {
    $href .= '?' . $ulang;
} else {
    $href .= '&' . $ulang;
}

$registry->setValue("config.multilingual_support", true);
global $mainframe;

$mainframe->setUserState('application.lang',$jfLang->code);
$registry->setValue("config.jflang", $jfLang->code);
$registry->setValue("config.lang_site",$jfLang->code);
$registry->setValue("config.language",$jfLang->code);
$registry->setValue("joomfish.language",$jfLang);

$href = JRoute::_($href,false);

header( 'HTTP/1.1 303 See Other' );
header( "Location: ". $href );
exit();

5 - customise the 1st line of the PHP code, to contain the language code that you want to use ("de" in this case).

6 - save the rule, and create an additional rule for each language/domain combination. Don't forget to edit the language short code in both the "exclude these languages" box AND in the PHP rule in the succeed action.

7 - if you want to set a particular template for each domain, don't try to incorporate it into the rules you just set up. Instead, make a new rule for each domain, that detects the domain and sets the appropriate template. Add these additional rules AFTER the previous ones, so that the redirects are detected first, then the template is changed if necessary.

Important note: this works ONLY for Joomla 1.5 and JoomFish. It *may* work with 3rd-party SEF components (e.g. sh404sef) but I haven't tested it.

Hope this helps,
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
3319 Posts
User info in posts
Administrator has disabled public posting

Re: Template & language based on domain

Thanks for the extended responds! I'll try to do tat and see if it works for us.

FYI, we are now using the Joomfish router to set language per domain name.

GrtZ

Joris

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

Re: Template & language based on domain

Hi Stephen,

Hi Stephen,

thanks it works!

One more question about the PHP code. Should "$href="http://www.metamodpro.com//index.php";" be changed into our domain name…? And does it need the www and double //

GrtZ,

Joris

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

Re: Template & language based on domain

Hi Joris,

I think that the e-mail you received from the forum has messed up the code slightly. See the post above: the $href command has only "index.php" and not the double slashes or anything else. That should solve that particular problem I think. I notice that on the Dutch site the home page resolved to //index.php?lang=nl if you don't have any cookies set for the domain, and the page does not display right. Hopefully that will be fixed by changing the href to just "index.php".

Amazing products, by the way!!!

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

Re: Template & language based on domain

Hi again, just another question:

How did you set things up in JoomFish so that on both domains you don't have the "/en/" or "/nl/" prefixes on the URLs? I couldn't manage to do this when I was trying to set it up on my site yesterday.

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

Re: Template & language based on domain

You can set this up in the plugin JFrouter. You choose use Sef subdomain.

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

Re: Template & language based on domain

Ah, perfect. The "subdomain" terminology was confusing me. In more recent versions of JF they changed this to "domain" which makes more sense.

I've already sent you this info off-line, but I've made a new version of my JFSEFRouter plugin for JoomFish, that allows you to use more than one domain per language. You simply use a comma-separated list of domains per language instead of a single domain name per language. The canonical domain always goes 1st in the list, e.g. 'www.example.com,example.com'.

I'll make this available on this site after you've confirmed it works for you.

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

Re: Template & language based on domain

Dear Stephen,

I've just upgraded  a long overdue upgrade from 1.5 to Joomla 3.3

I'm using Falang as joomfish replacement for my languages as I have so many menu's and languages; and I loved how Joomfish worked. But it seems that the rules I want to make in Chameleon, to load a specific language (ao. Dutch for our .nl domains and German for our .de domains), are not working. Could this be because of Falang or I'm I setting up these rules wrong. I'm getting an infinite loop error. 

I'm trying to set it up simple and per language:
Environment = a certain domain or various domains separated by commas
Action = a certain language 

FYI in joomla 1.5 I used Jsefrouter to load the languages.

I hope you can give me a quick responds, so I can solve the problem and go live with our 3.3 website. 

Thanks in advance.

Joris

Edited By: joris
24-Jul-14 08:25:23

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

Board Info

Board Stats:
 
Total Topics:
1674
Total Polls:
6
Total Posts:
5917
Total Posts Today:
5
User Info:
 
Total Users:
11538
Newest User:
michael2155
Members Online:
4
Guests Online:
241


Forum Legend:

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