Showing different embed template based on referrer

Post Reply
Psytonic
Posts: 15
Joined: Tue Jul 09, 2013 11:30 am

Showing different embed template based on referrer

Post by Psytonic »

Ok, let's say traderA.com visits the index page of my tube site, how can I show them a different video/embed page template once they click through the site to those pages? Normally once they hit the index and then to the category > video pages the referrer is now own domain, not the original ref. I'm pretty certain this could be done somehow with htaccess.

I've used referrer checking before to show a different template on a page like this:

Code: Select all

RewriteCond %{HTTP_REFERER} traderA.com [OR]
RewriteCond %{HTTP_REFERER} traderB.com [OR]
RewriteCond %{HTTP_REFERER} traderC.com
RewriteRule ^index.php$ new.php [L]
Would just love to be able to do that with the video pages too. I thought maybe something like this could work:

Code: Select all

RewriteCond %{HTTP_REFERER} traderA.com
RewriteCond %{QUERY_STRING} ^(.+)$ 
RewriteRule ^video/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/index.html$ /scj/tube/?slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/$ /scj/tube/?slug=$1&force_template=embed2 [L]
RewriteRule ^video/([^/]+)/([0-9]{1,2}).html$ /scj/tube/?slug=$1&item_id=$2&force_template=embed2 [L]
Any ideas?
admin
Site Admin
Posts: 37202
Joined: Wed Sep 10, 2008 11:43 am

Re: Showing different embed template based on referrer

Post by admin »

Are you sure you need a separate template or you need just a couple of modifications in an existing one?
Don't forget to run script update
Psytonic
Posts: 15
Joined: Tue Jul 09, 2013 11:30 am

Re: Showing different embed template based on referrer

Post by Psytonic »

I thought a separate template would be the only way because some of the html/javascript code will be different on this template to the standard one. Overall not much code will be different. The same related videos will be shown and the same video embeds/descriptions etc etc.
Psytonic
Posts: 15
Joined: Tue Jul 09, 2013 11:30 am

Re: Showing different embed template based on referrer

Post by Psytonic »

It's really just a code block or two that I want shown to specific referrers.
admin
Site Admin
Posts: 37202
Joined: Wed Sep 10, 2008 11:43 am

Re: Showing different embed template based on referrer

Post by admin »

You can add

if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com') {

your code

}
Don't forget to run script update
Psytonic
Posts: 15
Joined: Tue Jul 09, 2013 11:30 am

Re: Showing different embed template based on referrer

Post by Psytonic »

Thankyou, and if I want to use multiple traders? Something like:
if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com|trader2.com|trader3.com') {
??
admin
Site Admin
Posts: 37202
Joined: Wed Sep 10, 2008 11:43 am

Re: Showing different embed template based on referrer

Post by admin »

if ($GLOBALS['SCJ_VISITOR']['trader'] == 'trader.com' or $GLOBALS['SCJ_VISITOR']['trader'] == 'trader2.com')

dedicate 20 minutes of your time to read about basic PHP syntax , it'll save you a lot of time
Don't forget to run script update
Post Reply