Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Targeting ads within the category template

Quote Reply
Targeting ads within the category template
I'm used to using Links with site_html.pl and had the following in place to set variables for my SSI banner calls:

if ($category_clean =~ /^Art/) {$adzoneban="QAA"; $adzonebut="QAB"; $adzonetxt="QAC"; $adzonen = "Art, etc";}
elsif ($category_clean =~ /^Busin/) {$adzoneban="QBA"; $adzonebut="QBB"; $adzonetxt="QBC"; $adzonen = "Business, etc";}
elsif ($category_clean =~ /^Chari/) {$adzoneban="QCA"; $adzonebut="QCB"; $adzonetxt="QCC"; $adzonen = "Charity, etc";}
elsif ($category_clean =~ /^Compu/) {$adzoneban="QDA"; $adzonebut="QDB"; $adzonetxt="QDC"; $adzonen = "Computers, etc";}
elsif ($category_clean =~ /^Educa/) {$adzoneban="QEA"; $adzonebut="QEB"; $adzonetxt="QEC"; $adzonen = "Education, etc";}
elsif ($category_clean =~ /^Enter/) {$adzoneban="QFA"; $adzonebut="QFB"; $adzonetxt="QFC"; $adzonen = "Entertainment, etc";}
elsif ($category_clean =~ /^Gover/) {$adzoneban="QGA"; $adzonebut="QGB"; $adzonetxt="QGC"; $adzonen = "Government, etc";}

etc ... I then simply placed the $adzonexxx variable in each banner call, and voila targeted ads :)

I'm trying to do this with the category.html template, but haven't got a clue how to do it. I'm assuming I can do a <%if cat_clean has "xxx" at the start, use the following codes> - any help appreciated.

All the best
Shaun

Quote Reply
Re: Targeting ads within the category template In reply to
It would probably be better to use <%include%> files using a parameter set in the Category header.

You can also wait for the next release of Links SQL which will have an integrated banner/ad system so the hooks for this will be in place to expand upon.


http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Targeting ads within the category template In reply to
I've started work now on my LinksSQL installation (my ISPs server has been up and down for the past 5 days with problems), and I've come up with this in HTML_Templates.pm:

sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
#
my ($tags, $dynamic, $zonea, $zoneb, $zonec, $zonename) = @_;
my $template = defined $dynamic ? $dynamic->param('t') : undef;
(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";

my ($name) = $tags->{'category_name'} =~ m,/?([^/]+)$,;
defined $dynamic and &load_user ($dynamic, $tags);


if ($name =~ /^Anim/) {$zonea="QAA"; $zoneb="QBA"; $zonec="QCA"; $zonename = "Animals, etc";}
elsif ($name =~ /^Arts/) {$zonea="QAB"; $zoneb="QBB"; $zonec="QCB"; $zonename = "Arts, etc";}
elsif ($name =~ /^Busi/) {$zonea="QAC"; $zoneb="QBC"; $zonec="QCC"; $zonename = "Busines, etc";}
elsif ($name =~ /^Care/) {$zonea="QAD"; $zoneb="QBD"; $zonec="QCD"; $zonename = "Career, etc";}
elsif ($name =~ /^Comp/) {$zonea="QAE"; $zoneb="QBE"; $zonec="QCE"; $zonename = "Computers, etc";}
elsif ($name =~ /^Disa/) {$zonea="QAF"; $zoneb="QBF"; $zonec="QCF"; $zonename = "Disability, etc";}
elsif ($name =~ /^Educ/) {$zonea="QAG"; $zoneb="QBG"; $zonec="QCG"; $zonename = "Education, etc";}
elsif ($name =~ /^Ente/) {$zonea="QAH"; $zoneb="QBH"; $zonec="QCH"; $zonename = "Entertainment, etc";}
elsif ($name =~ /^Fina/) {$zonea="QAI"; $zoneb="QBI"; $zonec="QCI"; $zonename = "Finance, etc";}
elsif ($name =~ /^Game/) {$zonea="QAJ"; $zoneb="QBJ"; $zonec="QCJ"; $zonename = "Games, etc";}
elsif ($name =~ /^Gove/) {$zonea="QAK"; $zoneb="QBK"; $zonec="QCK"; $zonename = "Government, etc";}
elsif ($name =~ /^Heal/) {$zonea="QAL"; $zoneb="QBL"; $zonec="QCL"; $zonename = "Health, etc";}
elsif ($name =~ /^Home/) {$zonea="QAM"; $zoneb="QBM"; $zonec="QCM"; $zonename = "Home, etc";}
elsif ($name =~ /^Inte/) {$zonea="QAN"; $zoneb="QBN"; $zonec="QCN"; $zonename = "Internet, etc";}
elsif ($name =~ /^News/) {$zonea="QAO"; $zoneb="QBO"; $zonec="QCO"; $zonename = "News, etc";}
elsif ($name =~ /^Recr/) {$zonea="QAP"; $zoneb="QBP"; $zonec="QCP"; $zonename = "Recreation, etc";}
elsif ($name =~ /^Refe/) {$zonea="QAQ"; $zoneb="QBQ"; $zonec="QCQ"; $zonename = "Reference, etc";}
elsif ($name =~ /^Scie/) {$zonea="QAR"; $zoneb="QBR"; $zonec="QCR"; $zonename = "Science, etc";}
elsif ($name =~ /^Shop/) {$zonea="QAS"; $zoneb="QBS"; $zonec="QCS"; $zonename = "Shopping, etc";}
elsif ($name =~ /^Soci/) {$zonea="QAT"; $zoneb="QBT"; $zonec="QCT"; $zonename = "Society, etc";}
elsif ($name =~ /^Trav/) {$zonea="QAU"; $zoneb="QBU"; $zonec="QCU"; $zonename = "Travel, etc";}
else {$zonea="QAST"; $zoneb="QBST"; $zonec="QCST"; $zonename = "Quick Links";}

my ($za) = $tags->{'zonea'} = $zonea;
my ($zb) = $tags->{'zoneb'} = $zoneb;
my ($zc) = $tags->{'zonec'} = $zonec;
my ($zn) = $tags->{'zonename'} = $zonename;


my $output = &load_template ( 'category.html', {
%$tags,
build_links_per_page => $LINKS{build_links_per_page},
category_first => $name,
%GLOBALS
}, undef, $template );
defined $dynamic and &clean_output($dynamic, \$output);
return $output;
}
----------------------------------------------------------------------------------------------------

It works after a fashion, but seems to target the actual category itself, the last part of the full category name, i.e.; /Business/ - Fine, /Business/Test_Cat/ - not working, /Business/Test_Cat/Sub_Cat/ - not working, etc.

I want it to set a zone based on the first part of a category name, so that all /Business/... sub-cats are given the business zone variable, etc. I'm not a perl whiz and would appreciate any pointers to where I might be going wrong.

All the best
Shaun

Quote Reply
Re: Targeting ads within the category template In reply to
An even easier way is to define the footer and/or header in each category. Then all you need to do is add <%header%> or <%footer%> where you would like your banner and off you go!

Couldn't be easier, and you can change things quite easily without messing around with the code.

Regards,


Clint.

--------------------------
http://www.AffiliatesDirectory.com - Affiliate Programs Directory
Quote Reply
Re: Targeting ads within the category template In reply to
Thanks for the suggestion, but thats not how I want to do it. I would like LINKS to pass specific variables back to the template based on the first part of the category name.

i.e.; Business/Sub/Test/Sub - starts with Business so I want the relative zone codes passed back to the template so my ad program can call ads for those zones.

My problem is that I don't really understand how to get links SQL to make the variables and pass them back to the template, i.e.;

#INCLUDE VIRTUAL ="/path_to_cgi/ads/ad.pl?region=<%zonea%>&mode=SSI"

All the best
Shaun

Quote Reply
Re: Targeting ads within the category template In reply to
CRACKED IT! - I used the same system, checking against the catgeory name, but instead of HTML_Templates.pm I put it in nph-build.cgi and that did the trick Laugh

All the best
Shaun