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



Quote Reply
Re: Rating as Image Mod (For Links SQL NG!) In reply to
I installed this mod exactly as instructed. but the image doesn't show up. when I checked the image property, I found this: "http://.../images/rateUnknown Tag: 'rate_img'.gif", apparently, <%rate_img%> is the unknown tag. What could be wrong?

Thanks in advance.

Long

Quote Reply
Re: Rating as Image Mod (For Links SQL NG!) In reply to
Hi Long:

Did you make sure that the name that you give the subroutine is EXACTLY (case sensitive) as the variable you call?

dave

Quote Reply
Re: Rating as Image Mod (For Links SQL NG!) In reply to
Thanks, Deve

It's my fault! I put the globals into the admin section instead of default section. after I corrected this error, the mod works great. Thank very very much for the codes.

Long

Quote Reply
Re: Rating as Image Mod (For Links SQL NG!) In reply to
Long:

Glad it worked for you!

d

Quote Reply
Re: Rating as Image Mod (For Links SQL NG!) In reply to
thanks for this mod, very useful.

Anyone got any other links for nice little stars. The link above is now dead.

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: [padders] Rating as Image Mod (For Links SQL NG!) In reply to
Did anyone ever find any alternative graphics for this that go up to ten points?