Hi -
I've developed a global for the current Amazon affiliate program that I think might be useful... it combines functionality for not only Links categories, but search terms as well.
For anyone who is not familiar, Amazon has implemented a way of delivering dynamic links to best selling books for certain keywords. This is great news for webmasters in general and LinksSQL users in particular because it is a simple matter of dynamically generating this "keyword" and then calling the Amazon javascript to your page using their provided code. This allows you, the web site owner, to deliver links to the specific books (or music, videos, games, etc) that your visitors are most likely to buy... those that are relevant to the content they are requesting! This means you can generate more sales and more commissions!
A quick overview on my approach to this global...
First, my particular directory has a great many categories (200,000+), with some being five, six, or seven "layers" deep. So, I had to figure out a way to try and deliver keyword phrases that will work well with the Amazon search function over the widest range possible. If you expiriment some with the "build a link" feature at the Amazon affiliate area, you'll see that phrases with too many words do not work very well and return just a generic ad, rather than the desired keyword-specific book links.
This makes it difficult to simply pass the entire Category into the Amazon javascript code, as you will often get undesirable (generic) results.
The following Global will take your entire category name (for example, "Entertainment : Games : Card Games : Poker : Rules") and remove top level categories from the beginning until the string is no more than the pre-defined "maximum" characters. I have this set to a default of 25 characters. So, the example category would return an Amazon search string of "Card Games Poker Rules" (It will also truncate search terms similarly). You might ask, why not just pass in the specific category name? Consider this very example... if you pass in just "Rules", you will NOT get the specific results you are looking for (i.e. you want Poker rules, not just "rules")... Likewise, truncating at the end instead of the beginning would also be undesirable, as you would end up with, in this case, "Entertainment Games", which will return some results, but not specific enough to your visitor.
So first, create the following Global:
amazon_term =>
sub {
my $tags = shift; # available tags
my $string;
if($tags->{category_name_escaped}) {
$string = $tags->{category_name_escaped};
}
elsif($tags->{term}) {
$string = $tags->{term};
}
$string =~ s/%2F/ /g;
my $maxchars = 25; # this value may be modified for desired results
until(length($string) <= $maxchars) {
my @words = split(/\s/, $string);
shift(@words);
$string = join(" ", @words);
}
$string =~ s/ /\%20/g;
$string =~ s/\+/\%20/g;
return $string;
} Then, in your templates, call the clobal like this:
<script src="http://rcm.amazon.com/e/cm?t=YOUR_AMAZON_AFFILIATE_NAME_HERE&<%if category_id or query%>l=st1&search=<%amazon_term%>&mode=books&p=14&o=1<%else%>p=14&o=1&l=bn1&browse=1000&mode=books<%endif%>" type="text/JavaScript"></script><noscript>
<MAP NAME="boxmap"><AREA SHAPE="RECT" COORDS="37, 588, 126, 600" HREF="http://rcm.amazon.com/e/cm/privacy-policy.html?o=1"><AREA COORDS="0,0,10000,10000" HREF="http://www.amazon.com/exec/obidos/redirect-home/YOUR_AMAZON_AFFILIATE_NAME_HERE"></MAP><img src="http://rcm-images.amazon.com/images/G/01/rcm/160x600.gif" width="160" height="600" border="0" usemap="#boxmap" alt="Shop at Amazon.com">
</noscript> Note, this specific linking method is for books... the mode can be altered for different items. Also, this code is for a tall, skinny box with six books listed. You will need to select your preferred linking method and place the global call as above.
Another note, the <%else%> part above ensures that general bestsellers are returned on your LinksSQL home page (and other pages, like New/Cool/etc) where no "category_id" or "query" exist.
This global works well over a wide range of categories. It is not the "perfect" solution, as some categories will not give any results, and some will give strange results, but by and large, it is a good solution for a wide and/or deep category structure. If your directory has only a few categories, you may get better mileage from a slightly different approach. (Perhaps simply passing only the category name, or if that is not feasible, possibly adding a new column to your category table "amazon_term" and then assigning values by hand for each category and then use that value to pass through the Amazon javascript... Although this global should still work well for you.)
I hope the above is helpful. Any comments or feedback are welcomed.
--
Matt G