Gossamer Forum
Home : Products : Links 2.0 : Customization :

Replace Rating with Variable Image?

Quote Reply
Replace Rating with Variable Image?
Has anyone does this? For instance, the way Amazon.com shows a certain number of stars depending on the rating.

It seems to me that it would be very similar to Bobsie's 3 levels of NEW graphics. I'll try to figure it out if no one else has already done it.

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Phoenix,

What you might want to do is to setup a counter script. Have the images used be stars and then create the call to it something like this:

http://phoenix.com/cgi-bin/counter.pl?number=<%Votes%>&rating=<%Rating%>

It will probably only need either the rating or the votes but I used both to give you an idea. You know this would be a cool mod for the number of hits too...make 'em a nice graphic image that ties into the site.

Especially 'cause I took out the text hits thingy...and put it in the Alt tag of the Cool Sites, so visitors rarely even know how many times other sites have been viewed.

Well Good Luck Smile

Let me know what you got if you do it...

Rod

PS: Yeah What Rod said! Cute...


[This message has been edited by phoule (edited April 12, 1999).]
Quote Reply
Re: Replace Rating with Variable Image? In reply to
phoenix,

Does your server have the GD.pm module installed...if check out this guys site look for scritte.cgi

http://simi.polito.it/perl/index.html

It's a pretty cool tool for creating gif's on the fly using any text! Technically with this script you could make every single text link into a gif image...they are pretty small gif's too, only like 1-2 KB a piece so it shouldn't slow down your site delivery tremendously!

It's not quite what you are looking for but I cme across this while looking for a ggod prog that could handle what you were thinking of (No luck with it...but once I saw this I got engrossed) Smile

Rod

[This message has been edited by phoule (edited April 12, 1999).]
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Rod,

Thanks for the ideas. I will play around with this and let you know what I can come up with.

And yeah, Smile I thought it was cute!

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
So I went and did this. It wasn't hard at all with Bobsie's 3-levels of new mod to base my work on. It would have taken considerably less time had I know to use le to apply "less than or equal to" to a string. Anyway, the worst part was making the graphics for this. What a pain in the tush!

It's posted at my ISP site, http://www.asan.com/...nix/mod-ratings.html . If I here that it's working for people without trouble, I will add it to the Links Mods page.

Let me know what you think.

Oh, BTW Rod, for Hits, you could just take a plain single pixel colored gif, and set the height="5" and width="<%Hits%>" ... but then you run into a problem if you have a link with 1000 hits and it runs off the screen. To avoid that you make the width the # of hits divided by 3 or another number. Poor man's way of doing things, but I think it could be made to work out well.

Phoenix

Quote Reply
Re: Replace Rating with Variable Image? In reply to
Phoenix,

Works great. I like it very much. Thanks for the mod.
Quote Reply
Re: Replace Rating with Variable Image? In reply to
You must have the patience of a saint to shave those stars into 1/4 pieces! You figured this one out in a hurry too...hat's off!
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Thanks Brad! Smile

I was so frustrated with making those stars, I nearly added to the bottom of the web page, "And if you need images for a dark background or an image other than stars, I am NOT the person to ask!"

But I thought better of it. Wink

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Phoenix,

I sent you an image set I made. Did you get it? Excellent mod!

The approach I took with my images was to gray out the part of the image not used (i.e. an 8 out of 10 shows the same amount as a 10 out of 10, but the last 20% is sort of a shadowed look). I think this is a little cleaner than leaving blank space, and is probably an easier way to make the images. Also, I made the background transparent, which is equally easy with something like paint shop pro.

If anyone's interested at looking at my images (running shoes instead of stars), they're at:
http://www.dankaplan.com/runninglinks/
It's still in the testing stage (not linked up to my site) so some stuff is not yet finished.

Dan
Quote Reply
Re: Replace Rating with Variable Image? In reply to
I'm going to have to try this one out. I like the idea, thanks for posting it. Five stars looks much better and is more consistent with the typical rating scheme. One size fits all if the background is transparent (I think people will catch on soon enough what the rating scheme is).

[This message has been edited by Dave (edited April 16, 1999).]
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Just to let everyone know, I've posted quite a few additional image sets for this mod to the web page at http://www.asan.com/...nix/mod-ratings.html which were contributed by Crowe, Dan, and Dave. Thanks for the contributions! I'll continue to post new image sets to the page as I create them or receive them from others.

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
For site_html.pl users its a real easy mod. All you need to do is add something like the following in sub site_html_link.

if ($rec{'Rating'} eq '0') { $output .= qq~ ~; }
elsif ($rec{'Rating'} le '1.00') { $output .= qq~ <IMG SRC="path/1.gif">~; }
elsif ($rec{'Rating'} le '1.50') { $output .= qq~ <IMG SRC="path/1_5.gif">~; }
elsif ($rec{'Rating'} le '2.00') { $output .= qq~ <IMG SRC="path/2.gif">~; }
elsif ($rec{'Rating'} le '2.50') { $output .= qq~ <IMG SRC="path/2_5.gif">~; }
elsif ($rec{'Rating'} le '3.00') { $output .= qq~ <IMG SRC="path/3.gif">~; }
elsif ($rec{'Rating'} le '3.50') { $output .= qq~ <IMG SRC="path/3_5.gif">~; }
elsif ($rec{'Rating'} le '4.00') { $output .= qq~ <IMG SRC="path/4.gif">~; }
elsif ($rec{'Rating'} le '4.50') { $output .= qq~ <IMG SRC="path/4_5.gif">~; }
elsif ($rec{'Rating'} le '5.00') { $output .= qq~ <IMG SRC="path/5.gif">~; }
else { $output .= qq~Somebody goofed~; }

I'm only using nine images and a 1 - 5 rating scale. To change the rating scale all you need to do is delete <option>6-10 in sub site_html_rate_form.

[This message has been edited by Dave (edited April 17, 1999).]
Quote Reply
Re: Replace Rating with Variable Image? In reply to
phoenix, thnx for the mod, I've installed it and it works great.

However, one little problem I see is that if a site has one vote and rated as a 10, it gets 10 stars, and for new sites, webmasters tend to go in right away and rate their site as a 10 for themselves.

Would there be an easy way to check that there was at least 10 votes before it put in a rating?
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Good point, lunaria.

I haven't actually tried this, but it looks like it should work. It's just adding an extra if-else statement around the one that already exists in the site_html_template.pl file

Code:
if ($rec{'Votes'} ge '10') {
if ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
...(snipped for brevity)...
else { $rate_img = $rate_20; }
else { $rate_img = $rate_00; }
}

That should make it show the "No Votes Yet" image (which you could alter to say "Less than 10 votes" if you wanted) appear until there are at least 10 votes, and then begin to show the rating system.

Hope this helps. Let me know if it works like you wanted.
Phoenix

[This message has been edited by phoenix (edited May 13, 1999).]
Quote Reply
Re: Replace Rating with Variable Image? In reply to
When I tried what you said, I got a syntax error, so I moved the bracket to this.
Code:
if ($rec{'Votes'} ge '10') {
if ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
clipped..
else { $rate_img = $rate_20; }
}
else { $rate_img = $rate_00; }

but that still didn't work.
I also tried
Code:
if ($rec{'Votes'} le '10') { $rate_img = $rate_00; }
elsif ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
clipped...
elsif ($rec{'Rating'} le '9.50') { $rate_img = $rate_19; }
else { $rate_img = $rate_20; }

But that didn't work either.. any ideas?
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Greetings..

I'm running Links 2.0 using templates and the Yahoo template.

I'm having troubles getting this mod to work. When I try to insert the <%rate_img%> tag into my link.html template it will only show "Unkown Tag: rate_image" once for every link that should show up. I have posted my modified sub site_html_link Here: http://www.aquariacentral.com/temp.txt

Could someone please take a look at it and see what I've done wrong? Thank you


------------------
Michael McEwan
www.aquariacentral.com
Quote Reply
Re: Replace Rating with Variable Image? In reply to
anyone else has the description how to make
the modification besides phoenix's site? cuz
i could never connect to his server www.asan.com
Quote Reply
Re: Replace Rating with Variable Image? In reply to
maky,

If you write to me (the email icon on this message) to get me your address, I'll email you the page.

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Nice mod... has anybody tried to put the variable rating image on the detailed page as well? I have not been able to get that to work.
Quote Reply
Re: Replace Rating with Variable Image? In reply to
oldmoney,

Yes, I've got the ratings images showing up on detailed pages as well. I simply took all the instructions for what to add to sub site_html_link and did the exact same thing under sub site_html_detailed.

There is a somewhat less wordy way to do this, but so far I've been too lazy to make it shorter. Smile

Phoenix
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Thanks for the tip. Got it to work as well. If I ever I get this site finished, perhaps I too will go back and find a way to reuse the code.
Quote Reply
Re: Replace Rating with Variable Image? In reply to
I have the same problem as Michael

I'm having troubles getting this mod to work. When I try to insert the <%rate_img%> tag into my link.html template it will only show "Unkown Tag: rate_image" once for every link that should show up.

What should i do?



code:

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like. It's a little complex looking just because we have to
# check for blank entries..

my (%rec) = @_;
my $rate_img = "";

$rate_00 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate00.gif" WIDTH=160 HEIGHT=16 ALT="Rate It!" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_01 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate01.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_02 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate02.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_03 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate03.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_04 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate04.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_05 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate05.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_06 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate06.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_07 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate07.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_08 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate08.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_09 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate09.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_10 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate10.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_11 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate11.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_12 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate12.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_13 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate13.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_14 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate14.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_15 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate15.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_16 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate16.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_17 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate17.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_18 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate18.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_19 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate19.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;

$rate_20 = qq|<a href="$db_cgi_url/rate.cgi?ID=$rec{'ID'}"><IMG SRC="/images/rate20.gif" WIDTH=160 HEIGHT=16 ALT="Rating: $rec{'Rating'}, $rec{'Votes'} Votes" BORDER="0" ALIGN="ABSMIDDLE"></A>|;


if ($rec{'Rating'} eq '10.00') { $rate_img = $rate_20; }
elsif ($rec{'Rating'} eq '0') { $rate_img = $rate_00; }
elsif ($rec{'Rating'} le '0.50') { $rate_img = $rate_01; }
elsif ($rec{'Rating'} le '1.00') { $rate_img = $rate_02; }
elsif ($rec{'Rating'} le '1.50') { $rate_img = $rate_03; }
elsif ($rec{'Rating'} le '2.00') { $rate_img = $rate_04; }
elsif ($rec{'Rating'} le '2.50') { $rate_img = $rate_05; }
elsif ($rec{'Rating'} le '3.00') { $rate_img = $rate_06; }
elsif ($rec{'Rating'} le '3.50') { $rate_img = $rate_07; }
elsif ($rec{'Rating'} le '4.00') { $rate_img = $rate_08; }
elsif ($rec{'Rating'} le '4.50') { $rate_img = $rate_09; }
elsif ($rec{'Rating'} le '5.00') { $rate_img = $rate_10; }
elsif ($rec{'Rating'} le '5.50') { $rate_img = $rate_11; }
elsif ($rec{'Rating'} le '6.00') { $rate_img = $rate_12; }
elsif ($rec{'Rating'} le '6.50') { $rate_img = $rate_13; }
elsif ($rec{'Rating'} le '7.00') { $rate_img = $rate_14; }
elsif ($rec{'Rating'} le '7.50') { $rate_img = $rate_15; }
elsif ($rec{'Rating'} le '8.00') { $rate_img = $rate_16; }
elsif ($rec{'Rating'} le '8.50') { $rate_img = $rate_17; }
elsif ($rec{'Rating'} le '9.00') { $rate_img = $rate_18; }
elsif ($rec{'Rating'} le '9.50') { $rate_img = $rate_19; }
else { $rate_img = $rate_20; }












return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rate_img,
%rec,
%globals

});
}



------------------
-------------------------
http://www.freeontheweb.com/
Reviewed and rated resources for webmasters
-------------------------
Quote Reply
Re: Replace Rating with Variable Image? In reply to
Try using <%rate_img%> instead of <%rate_image%>.

I hope this helps.