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.

 

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

Thank you for your help Stephen!

Ray.

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

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.

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

Re: Moducels based on referer URL,

Thank you stephen...

I'm still a relative noob with PHP and I forgot that PHP can set cookies, even though I learned in my PHP class! doh!

Thanks for this!

Ray.

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

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10091
Newest User:
lamanaudio
Members Online:
3
Guests Online:
86


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked