Page 1 of 1

multi domain & language

Posted: Wed Jun 18, 2014 5:11 am
by hungphan
Can someone help me with this script...?
<?php
$lang = JFactory::getLanguage();
$result=$lang->getTag();
if ($result=='en-GB'){allang = '<img src="English.jpg">';}
if ($result=='vi-VN'){allang = '<img src="TiengViet.jpg">';
else {allang = '<img src="other.jpg">';}

$host = $_SERVER['HTTP_HOST'];
if($host == 'www.domain1.org' or $host == 'domain1.org') {$text = allang;}
if($host == 'www.domain2.net' or $host == 'domain2.net') {$text = 'Not Using';}
echo $text;
?>
If English, it will display English image.
If Vietnamese, it will display Vietnamese image.
But only display on the domain that I want to.
Because I want to use one module for multi domains...

Re: multi domain & language

Posted: Wed Jun 18, 2014 5:34 am
by duyet
allang should be $allang ...

for domain2 you can set $text = ''; which is easier to check iso some string ...

also i think you need a right path to your images.

Re: multi domain & language

Posted: Wed Jun 18, 2014 8:30 pm
by hungphan
<?php
$lang = JFactory::getLanguage();
$result=$lang->getTag();
if ($result=='en-GB'){$allang = '<img src="vietnamese.jpg">';}
if ($result=='vi-VN'){$allang = '<img src="english.jpg">';}
else {$allang = '<img src="others.jpg">';} //Personel

$host = $_SERVER['HTTP_HOST'];
if($host == 'www.domain1.org' or $host == 'domain1.org') {
$text = $allang;}
if($host == 'www.domain2.org' or $host == 'domain2.org') {
$text = $allang;}
else {$text = $allang;}
echo $text;
?>
This script is working fine. But can we make it shorter on part 2 (from all domains)
Look like it is repeating...

Thank You!!!

Re: multi domain & language

Posted: Thu Jun 19, 2014 6:12 am
by duyet
your 2nd part doesn't make sense ... $text is always $allang! there is no need to test on host ...

so you can shorten it with:

Code: Select all

echo $allang
:)