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.

 

Control module by domain,

Control module by domain,

HI Metamodders,

My client has 4 different domains pointing at one joomla install:

mysite.com
mysite.co.uk

yoursite.com
yoursite.co.uk


Each is targeted at a different user i.e. international and UK based etc.


I'd like to be able to control modules based on the domain url.

So module 'a' shows when mysite.com is used and module 'b' shows when mysite.co.uk is used etc.

I think this may be done with this PHP:

Code:

if($_SERVER['SERVER_NAME']== "www.mysite.co.uk") return 101;

I'm working on offline dev so I can't test this.

Can this be confirmed?

Thank you!

Ray.

igolfniray
Beginner Modder
ranks
useravatar
Offline
16 Posts
Administrator has disabled public posting

Re: Control module by domain,

Hi all again,

I've just been able to test this out on a test sub-domain and I can confirm that this works as long as the "http://" bit of the url is omitted.

So this worked:

Code:

if($_SERVER['SERVER_NAME']== "test.mysite.co.uk") return 110;

This didn't:

Code:

if($_SERVER['SERVER_NAME']== "http://test.mysite.co.uk") return 110;

This is quite handy because with a bit of clever metamodding, I can build basically 4 (or more) different sites with one joomla install each tailored to international or domestic users etc.

COOL!

smile

igolfniray
Beginner Modder
ranks
useravatar
Offline
16 Posts
Administrator has disabled public posting

Re: Control module by domain,

Hi igolfniray,

yes, that's a good way to do it as long as your server populates the $_SERVER['SERVER_NAME'] variable with the correct thing. This is used for the Apache VirtualHost name.

An alternative is to use $_SERVER['HTTP_HOST'] which takes the hostname that the client actually used to reach you. This makes it easy to utilise multiple parked domains pointing to the same Joomla installation, and always respond to the domain name the the used actually specified in their client. This may sometimes come up with different results to the one you are using, depending on the exact way that Apache is set up on your server.

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

Re: Control module by domain,

is the syntax the same then Stephen?

ie:

Code:

if($_SERVER['HTTP_HOST']== "test.mysite.co.uk") return 110;

igolfniray
Beginner Modder
ranks
useravatar
Offline
16 Posts
Administrator has disabled public posting

Re: Control module by domain,

Yes, that should 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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1684
Total Polls:
6
Total Posts:
5940
Posts this week:
1
User Info:
 
Total Users:
5161
Newest User:
kbmgkey234q
Members Online:
0
Guests Online:
505

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