multi domain & language

General questions regarding the use of languages in Joomla! 2.5.

Moderators: infograf768, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
hungphan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Oct 02, 2013 10:40 pm

multi domain & language

Post by hungphan » Wed Jun 18, 2014 5:11 am

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...

User avatar
duyet
Joomla! Guru
Joomla! Guru
Posts: 935
Joined: Wed Sep 21, 2011 8:21 pm
Location: on earth
Contact:

Re: multi domain & language

Post by duyet » Wed Jun 18, 2014 5:34 am

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.

hungphan
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Oct 02, 2013 10:40 pm

Re: multi domain & language

Post by hungphan » Wed Jun 18, 2014 8:30 pm

<?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!!!

User avatar
duyet
Joomla! Guru
Joomla! Guru
Posts: 935
Joined: Wed Sep 21, 2011 8:21 pm
Location: on earth
Contact:

Re: multi domain & language

Post by duyet » Thu Jun 19, 2014 6:12 am

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
:)


Locked

Return to “Language - Joomla! 2.5”