I am trying to create an if statement that will show a banner to visitors only if they are from a certain website. This is what I have been working with and have placed in the central block of the template for the index page (…customer/blocks/locations/index/central):
{if $visitor.referrer == 'http://referringwebsite.com'}

{/if}
The $visitor.referrer portion came from the statistics addon (which shows where the visitor came from). Can anyone tell me why this isn't working? Thanks in advance!
I'm going to guess that $visitor isn't defined.
Try putting a {debug} tag above your code and then looking for $visitor in the pop-up debug window. If it's not there, then it isn't defined.
You can probably use something like:
{if $smarty.const._SERVER['REMOTE_HOST'] == 'referringwebsite.com'}
instead.
I guess I am way out of my league here, but when I insert the code from the reply above, I get the following error:
Fatal error: Smarty error: [in blocks/locations/index/central.tpl line 2]: syntax error: unidentified token '['REMOTE_HOST']' (Smarty_Compiler.class.php, line 1406) in /home/rattle5/public_html/lib/templater/Smarty.class.php on line 1095
Any thoughts? Thank you tbirnseth by the way.
Try
$smarty.const._SERVER.REMOTE_HOST
Nope…
Fatal error: Smarty error: [in blocks/locations/index/central.tpl line 1]: syntax error: $smarty._SERVER.REMOTE_HOST is an invalid reference (Smarty_Compiler.class.php, line 2130) in /home/rattle5/public_html/lib/templater/Smarty.class.php on line 1095
At least it was an “invalid reference” this time and not an “unidentified token”.
Thanks again for your help.
(the “const.” was included, but it wasn’t shown on the error message)
One last try:
$smarty.server.REMOTE_HOST
No error this time, but the banner did not display when I clicked through from the other site.
Thanks for trying…I appreciate it.
Then just for grins, just above your code add:
```php
Remote host is: {$smarty.server.REMOTE_HOST}
```
And then compare it to what you're testing for in your if statement.
I put it on my site:
After “Remote host is:”, nothing was displayed.
Try REMOTE_ADDR, your host may not do the lookup for REMOTE_HOST…
Sorry, these things are an iterative process and I can't do the iterations here.
Also, if your remote site goes through a proxy server, you could get a different IP for each session.
Adding REMOTE_ADDR brought up my ip address. No proxy server with my site.
Thanks.
The “referrer” for a page will only be valid on the first page access of the current session.
So you're going to need to capture your HTTP_REFERRER into a _SESSION variable and then test for that variable being what you want for your display.
So I would do something like this. Create addons/my_changes/controllers/customer/init.post.php file with contents of:
```php
if( !defined('AREA') ) die('Access denied');
if( !isset($_SESSION['my_referer']) ) {
$_SESSION['my_referer'] = @gethostbyaddr($_SERVER['HTTP_REFERER']);
}
?>
```
Then test for $smarty.session.my_referrer in your if statement.
Again, thank you for your help.
I have tried for the past few hours and I cannot get any of this to work correctly. The banner will simply not display when coming to my site from the referral site. I am out of ideas. I just don’t get how the referring website can be displayed in the statistics section of the admin, but I can’t get a simple if statement to work. 
I'm for hire if it's important to you. You can send me an email to tonybXX@ez-msXX.com (remove X's).
Probably 1/2 hr of work.