Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Rating as Image Mod (For Links SQL NG!)

Quote Reply
Rating as Image Mod (For Links SQL NG!)
Hi:

Had a bug in the earlier post, but all seems to be working fine now...

To display a rating as an image... like a five star rating, simply go over to Build in ADMIN, and choose Template Globals. Add a new code called rate_img.

Then, in the description box, enter:

In Reply To:

sub {
my ($rec) = @_;
if ($rec->{'Rating'} eq '10.00') {'20'; }
elsif ($rec->{'Rating'} eq '0.00') {'00'; }
elsif ($rec->{'Rating'} eq '') {'00'; }
elsif ($rec->{'Rating'} le '0.50') {'01'; }
elsif ($rec->{'Rating'} le '1.00') {'02'; }
elsif ($rec->{'Rating'} le '1.50') {'03'; }
elsif ($rec->{'Rating'} le '2.00') {'04'; }
elsif ($rec->{'Rating'} le '2.50') {'05'; }
elsif ($rec->{'Rating'} le '3.00') {'06'; }
elsif ($rec->{'Rating'} le '3.50') {'07'; }
elsif ($rec->{'Rating'} le '4.00') {'08'; }
elsif ($rec->{'Rating'} le '4.50') {'09'; }
elsif ($rec->{'Rating'} le '5.00') {'10'; }
elsif ($rec->{'Rating'} le '5.50') {'11'; }
elsif ($rec->{'Rating'} le '6.00') {'12'; }
elsif ($rec->{'Rating'} le '6.50') {'13'; }
elsif ($rec->{'Rating'} le '7.00') {'14'; }
elsif ($rec->{'Rating'} le '7.50') {'15'; }
elsif ($rec->{'Rating'} le '8.00') {'16'; }
elsif ($rec->{'Rating'} le '8.50') {'17'; }
elsif ($rec->{'Rating'} le '9.00') {'18'; }
elsif ($rec->{'Rating'} le '9.50') {'19'; }
else {'00'; }
}
You may have to adjust the number of elsif steps depending on how many images you run. Then, in your link.html templete, just use the following syntax to call the image:

Rating: <IMG SRC="http://path.to/images/rate<%rate_img%>.gif" ALT = "<%Rating%>" WIDTH=57 HEIGHT=10 BORDER=0>

Make sure to change the WIDTH and HEIGHT attributes, as appropriate.

I have bastardized the "ratings as grafic" Links 1.XX code by Robert to work in SQL NG, I hope he does not mind! You can see his original code here:

http://www.adeva.de/rateimg.htm

If you are in need of grafix, I originally got mine from the Links 2 resource forum here:

http://www.asan.com/...nix/mod-ratings.html

Phoenix Amon has some nice image sets there.

Well, that should do it! Good luck!

Dave



Subject Author Views Date
Thread Rating as Image Mod (For Links SQL NG!) carfac 3650 Nov 16, 2000, 8:29 PM
Thread Re: Rating as Image Mod (For Links SQL NG!)
long327 3522 Dec 12, 2000, 3:38 PM
Thread Re: Rating as Image Mod (For Links SQL NG!)
carfac 3491 Dec 14, 2000, 10:14 AM
Thread Re: Rating as Image Mod (For Links SQL NG!)
long327 3492 Dec 14, 2000, 10:54 AM
Thread Re: Rating as Image Mod (For Links SQL NG!)
carfac 3494 Dec 14, 2000, 10:57 AM
Thread Re: Rating as Image Mod (For Links SQL NG!)
padders 3410 Mar 19, 2001, 6:20 PM
Post Re: [padders] Rating as Image Mod (For Links SQL NG!)
alchemist 3219 Feb 10, 2002, 5:01 AM