Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Moducels based on referer URL,
Moducels based on referer URL,
Moducels based on referer URL,
Hi Stephen,
I was wondering if you could help me with this code based on one the recipes:
http://www.metamodpro.com/metamod/recip … eferer-url
I have created a directory called "client1" accessible in the root "http://www.mydomain/client1"
Inside there I've put an index.php file that redirects using the header/location code:
Code:
<?php
$host = $_SERVER['HTTP_HOST'];
header("Location: http://$host");
exit;
?>
So it redirects back to my home page. But I used this code to try to show my clients logo:
Code:
if ( $core_genius->check( "referer starts with http://www.mydomain.com/client1" )) {
return 98; /* module 98 is a Custom HTML with my clients logo */
}
(So basically I have 4 clients and I want them to 'feel' like they have their own site based in their own directory and URL 'http://www.mydomain.com/client1' 'http://www.mydomain.com/client2' etc.
So I need "/client1" to redirect to the home page and show module 98 and "/client2" to redirect to the home page and show module 99... etc etc...)
But I think the http isn't carrying over any referrer data during the redirect. I think it's doing a clean redirect as if the "http://www.mydomain.com/client1" was never entered.
Is there anyway I can get "http://www.mydomain.com/client1" to redirect to my homepage with some post data or any kind of data to allow metamod to 'see' something.
This is all before login, so my variable options are limited!
Thank you for your help Stephen!
Ray.
Re: Moducels based on referer URL,
Hi Ray,
Yes I think you are right that a Header redirect may not show up as a referrer.
However in most cases Joomla still has a session even when someone is not logged in -- or, you could use a cookie to associate that visitor with one of your clients.
e.g. in client1/index.php you add this code to what you're doing already:
setcookie( 'client', 'client1', time()+60*60*24*365*10, '/' );
Then in MetaMod you can detect the cookie and make decisions based on it:
$client = JRequest::getVar('client', '', 'cookie');
if ($client == 'client1') return XXX;
if ($client == 'client2') return YYY;
// etc...
else return ZZZ; // default if no client has been set
// replace XXX,YYY,ZZZ etc with the id of the module to use in each case.
- Index
- » MetaMod
- » MetaMod General Support
- » Moducels based on referer URL,
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 136
- 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