Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Still problems with banners on CGI-generated pages

Quote Reply
Still problems with banners on CGI-generated pages
Some of you should be getting sick of this question but I feel like there something wrong somewhere. Does someone have Webadverts displaying a banner on cgi generated pages?? I followed the instructions and it does not work.

Heres what I have one so far:

In site_html_templates.pl added a global variable to the list:
%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
banner => &insert_advert,
);

And added the insert_advert sub:

sub insert_advert {
require "/opt/guide/www.tracksonline.com/HTML/ads/ads_display.cgi";
$adverts_dir = "/opt/guide/www.tracksonline.com/HTML/ads";
$display_cgi = "http://www.tracksonline.com/ads/ads.cgi";
$advertzone = "";
$ADVUseLocking = 1;
$ADVLogIP = 0;
$DefaultBanner = "";
$ADVNoPrint = 1;
&ADVsetup;
}

In the templates I now use <%banner%> where I want a banner to appear but they don't. Instead of that there is now a banner in the admin area above the build all report. But only when using IE3.2 higher versions do not have this. So the sub is working. But not on the pages where it should be.

Related to version 2 I could not find a good answer in the forum. If someone could shine a light on this I would greatly appreciate it.

Jeroen Roeper
Tracks Online
http://www.tracksonline.com

Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Sorry I can't answer your questions but am curious, why you would use the webadverts $insertadvert tag at all, since the cgi built pages are static pages and not dynamically generated to conserve server overhead, so couldn't you just call the ad from the img src tag to webadverts as if you were calling it from a non ssi tag?
Unless of course you are having the script name your pages when built to .shtml which really wouldn't matter as you can just then add the exec cgi command to your templates or sitehtml file and it will insert those in the proper pages.
But..... If your using templates or not, why not call webadverts using the conventional img src tag?
Visionary
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
In reply to Visionary:

To prevent browser caching of the banners and due to the fact that I don't have a nonssi defined in Webadverts I want to use the Insertadvert routine. It supposed to work when adding the sub to the Globals. But it does not. I wonder why!!

The add form, search form and more are not static pages. They are loaded by the script and then send to the browser. SSI in this pages does not work. Since CGI output is not parsed by the server. When adding the insertadvert routine in the globals then the script is supposed to execute that routing whenevr you place <%banner%> in the templates. For some curious reason it does not do that. Perhaps Alex can tell us more about this???

Jeroen
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
I'm also having troubles with WebAdverts!

I've tried to paste the code...

sub insertadvert {
require "/home/httpd/cgi-bin/sirius/ads/ads_display.pl";
$adverts_dir = "/home/httpd/cgi-bin/sirius/ads";
$display_cgi = "http://wwnet.fi/cgi-bin/sirius/ads/ads.pl";
$advertzone = "";
$ADVUseLocking = 1;
$ADVLogIP = 0;
$DefaultBanner = "";
$ADVNoPrint = 1;
&ADVsetup;
}

...almost everywhere (search.cgi, site_html.pl, db_utils.pl, nph_build.cgi)

and after that I tried these
&insertadvert;
$insertadvert
in site_html.pl, but it never worked.

WebAdverts works fine in non-cgi pages so the problem is elsewhere. I'm using site_html.pl instead of templates.

[This message has been edited by Stigma (edited February 28, 1999).]
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Hi Jeroen,

Here's the changes you should make to get it to work.

1. Copy WebAdverts sub insert_advert { } into site_html_templates.pl.
2. Add the following to the globals:

banner => \&insert_advert

3. On CGI generated pages use:

<%banner%>

to display a banner.

4. On HTML pages (Home, New, Cool, Category, etc.) use SSI tags as normal.

Let me know how this works out!

Cheers,

Alex
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
OK we are half way,

It's displaying a banner now. But on top of the page. In the source code even above the <HTML> tag.

Take a look at http://freebies.tracksonline.com this is the homepage. The <%banner%> tag is in the add.html at the same position where the banner on the homepage is appearing (via SSI) Now look at the add page (click the link)

See the problem???

Jeroen
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Technically speaking there are only 20 some template files.
I was able to get the banner to run with no problem using the same script (webadverts).
Here are my way;
1. Make a html file to make sure your tags are right and the banner shows.
2. Take the tag and put it in every template files.
3. Go to your admin then build all.

It works quite nice for me

Hope this helps Smile
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
In reply to Visionary, and FYI to everyone else:

I use the IMG tags for webadverts on Links. I too had the concern of browser caching so did the following.

Where is says "page= " (this is where you can put in a variable to make the browser think it's a new image) I put <%grand_total%> Now when the script builds the pages it puts in the total links for that page into that variable. Thus the number should be different on each page, preventing the caching problem. (but remember to do it in BOTH places it says page= , once in img tag once in <a> tag)

It's not a perfect science,if you have two cats with the same number of links it will load the banner from the cache, but for me it works really well.

The exceptions are for new/cool/rate I put page=new etc. And for the search results it needs to be page=<%link_hits%> instead.

Aaron
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Jeroen,

Hmm. Can you email the author and ask him if it's possible to return the ad to be displayed as a string rather then print it?

The problem is calling &AdvSetup prints the ad using print(). Links does not display the page until all of it's been parsed. This means the ad get's displayed first, and then the rest of the page.

There might be an option you can use in WebAdverts to get around this.

Cheers,

Alex
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
I'm glad that Jeroen made it work for him, but I still can't figure it out what's the matter with mine!

As I told you before, I have inserted the sub insertadvert into my site_html.pl, but it still doesn't work! The same script works fine on static pages. The sub insertadvert is an exact copy of the original sub found in the ads.pl.

And to Visionary: If I used the img tag instead of the SSI call, the banners wouldn't have their ALT descriptions or normal text description texts above them.

I'd really appreciate your help.
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Hi Jeroen,

I've reached the same point as you. It may be a spurious remark, but I was really happy just to see a banner!

I checked out your page and I think if you 'centered' the banner it would look fine.

I'm not sure how you could accomplish this when the banner appears *before* the HTML, but it happened spontaneously on my pages!

Neil Shearing
shearing@scamfreezone.com
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Finally!!!!!!!!!!!!!!! THANX A LOT!
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Just type the followings to your Site_html_templates.pl

sub insertadvert {
my $ad = `/home/john/www/cgi-bin/ads/ads.pl`;
$ad =~ s,Content-type:\stext/html,,;
return $ad;
}

and under global call it like this

banner => \&insertadvert,

best Regards
Yasser

------------------
Best Regards
Yasser Al-Ghurazy
AOL S/N: SanaaNet
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Yasser,

I did exactly as you outline but my banners don't show up on cgi generated and non cgi pages. I am using templates.
Quote Reply
Re: Still problems with banners on CGI-generated pages In reply to
Yasser,

I did exactly as you outline but my banners don't show up on cgi generated and non cgi pages. I am using templates.