Gossamer Forum
Home : Products : Links 2.0 : Customization :

Add category images

Quote Reply
Add category images
Hi there

A friend has just wrote a mod to include a specific image for every category in links, depending if the image is on the server. If the image is not there, a default image appears. Here it is below.

#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser carpout);
use Getopt::Long;
use File::Basename;

$dir=$ENV{'DOCUMENT_ROOT'};
$category="something";#(you need to grab the category from the referring code here.)
#set the following path to the pictures folder relative to the root directory without leading and trailing slashes.
$path="/path/to/category/images";
$pctfile="$dir/$path/$category.gif";
if (-e $pctfile) {$picturefile=$category.gif";}
else{$picturefile="default.gif";}
print "content-type:text/html","\n\n";
print "<html>\n";
print "<head>\n";
print "</head>";
print "<body>\n";
print "<img src='$dir/$path/$picturefile'>\n";
print "</body>\n";
print "</html>\n";

I have one or two questions about this mod.

1. How would I call this script into the html of links (ssi?)

2.
' $category="something";#(you need to grab the category from the referring code here.) '

What exactly does this mean? How does this mod determine which Links category your in?

3. Please reply with any tips on getting this mod workining effectivly.

Thanks a lot;
Rich