Gossamer Forum
Home : Products : Links 2.0 : Customization :

my banner sub program in site_html_templates

Quote Reply
my banner sub program in site_html_templates
On all of my CGI generated pages such as review.cgi and myliks.cgi I'd like display a random banner advertisement. I added a new key at the end of the %globals hash in site_html_templates.pl:

In Reply To:
banner => &random_banner
The random_banner sub program looks like this:

In Reply To:
sub random_banner {
$banner_file = "/cgi-bin/banners/banners.txt";
open(BANNERS, $banner_file);
srand;
rand($.) < 1 && ($line = $_) while <BANNERS>;
return $line;
}
Banners.txt contains lines of html, each line is the code for one banner. Finally, in my templates, I tried to call the banner with a "banner" tag with percent signs (it doesn't post correctly in the fourm).

Although the banner doesn't display, I don't get an unknown tag error. I have tested this random_banner sub as I standalone CGI program and it works fine.

What am I doing wrong?

Quote Reply
Re: my banner sub program in site_html_templates In reply to
Try using your complete ABSOLUTE path to where your banner.txt file is located. It won't work with relative paths as you have shown.

Regards,

Eliot Lee
Quote Reply
Re: my banner sub program in site_html_templates In reply to
Duh! Thanks for pointing that one out. What was I thinking?