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.

 

Referrer example?

Referrer example?

I'm looking to use the function that changes template depending on the site/page the visitor comes from. I interpret this as the referrer site/page. (Correct?)

If a person arrives from "http://www.Asite.com/pageC" on "http://www.MYSITE.com/home" I use the default template and if anyone comes from ANYOTHER site or page the template is different.

I have been able to understand and modify other rules with examples you supplied, but it would be good to have an example of this refrrer rule... Is there a cookbook of examples anywhere?

Thanks
Lion

Lion Benjamins
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Referrer example?

Hi Lion,

yes, that's correct: the referrer is the page that contained a link to the page that the person is now viewing. So if they were on http://www.Asite.com/pageC then clicked on a link to http://www.MYSITE.com/home, then a test in Chameleon on MYSITE.com will show the referrer as exactly http://www.Asite.com/pageC

Note that if www.Asite.com/pageC was actually a redirect, then it works slightly differently depending on what sort of redirect and what browser the person uses. But for a standard webpage, this should work fine as long as both pages are http. If the link is from an https page to an http page, then the referrer is NOT passed through to the 2nd site.

You are asking how to set this up. There are 2 ways depending on whether you want the new template to last for only the 1st page, or for the rest of the session.

New template only on the landing page (1st page on your site after linking from somewhere else):

1 - create new Chameleon rule
2 - enter the referrer as http://www.Asite.com/pageC
3 - enter the URL as http://www.MYSITE.com/home
4 - since under these conditions you want the default template, then in the Succeed action DON'T set a new template, and just ensure that "stop processing" is selected in the Succeed action. This prevents the next rule from being run.
5 - save the Chameleon rule, and create a new one.
6 - in the 2nd rule, again enter the URL as http://www.MYSITE.com/home
7 - in the Succeed action, set the template to the new template.
8 - save the rule.

In this way, the 1st rule detects the case where your landing page was hit based on the specific referrer. It then exits gracefully without changing the template.
The 2nd rule is only run if the 1st one fails. It then checks again for the landing page. If it finds the landing page, then it knows that it CAN"T come from the specified referrer (since that would be caught by the previous rule). So it must be from a different referrer, and it goes ahead and changes the template.

Now, that technique is fine except if you want the "new" template to be remembered for the rest of the session. if you want that, you need to use the Session Variable or Permanent Cookie features. Instead of the steps above, use these ones:

1 - create Chameleon rule 1
2 - in the Quick section, "detect session variable A"
3 - in the Succeed action, set the new template and "stop processing"
4 - save the rule and create rule 2
5 - in rule 2, detect the referrer and URL as in steps 2-3 above.
6 - in rule 2, in the Succeed action, "stop processing"
7 - save rule 2 and create rule 3
8 - in rule 3, detect only the URL
9 - in rule 3, in the Succeed action, do 2 things: (a) set the new template, and (b) "Set session variable A"
10 - save rule 3.

In this way, when the new template gets triggered, a session variable is also set. When the user goes to the next page on your site, that session variable is detected in rule 1, and this causes the new template to be set no matter what page the user is on.

I hope that helps,
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

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Posts this week:
4
User Info:
 
Total Users:
5527
Newest User:
briggs78w
Members Online:
0
Guests Online:
142

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