Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Control module by domain,
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.
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!
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
- Index
- » MetaMod
- » MetaMod General Support
- » Control module by domain,
Board Info
- Board Stats:
- Total Topics:
- 1700
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 8052
- Newest User:
- maarie443
- Members Online:
- 0
- Guests Online:
- 181
- 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