Gossamer Forum
Home : Products : Links 2.0 : Customization :

ratings amazon-image-style mod problems

Quote Reply
ratings amazon-image-style mod problems
I'm using templates and installed the image rating mod. Something weird is happening in that sometimes a link has 1 vote with a rating of 10. Instead of pointing to the right image it points to image 04. I looked in the code and nothing makes me think it should be 4. What's bizarre is that it lists the rating correctly, and since the alt tag uses the same variable why should the image be wrong and the number be right?

------------------
http://www.diamondgrading.com
Learn about Diamonds from former Gem-Lab Graders
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
you should use my code..

i didn't feel like adding it to the resource center.. it's much shorter..

add this to the end of site_html_templates.pl

Code:
sub get_rating_image {
my ($rating) = @_;
my ($i, $image);

for ($i = 0; $i <= 20; $i++) {
$image = qq~<img src="$rating_images_url/rate$i.gif" width="94" height="20" alt="$rating" border="0">~ and last if ($rating <= $i/2);
}

return $image | | $rating;
}

delete the space between the "| |".. the message board screws it up

in links.cfg add this:

Code:
$rating_images_url = $build_root_url . "/images/ratings";

under:

Code:
$build_ratings_url = "$build_root_url/Ratings";

and change it to the proper location of where your images will be.. also.. change the width and the height to the size yours is going to be..

umm... now in site_html_link.. you would put something like this (i think you should know where)..

Code:
rate_img => &get_rating_image($rec{'Rating'}),

you will need to rename your images to.. rate0-rate20.. instead of rate00-rate20.. if you get what that means.. (ie: rate1, rate2, rate3.. instead of rate01, rate02, rate03..)

ok.. that's all..

jerry

[This message has been edited by widgetz (edited September 06, 1999).]
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Thanks Jerry!

Well, I almost got it, but got confused about a couple of things... first:

"you should use my code....add this to the end of site_html_templates.pl"

OK, does this mean I need to delete anything from the mod's code? Or I just need to add what you're saying?

Second:
"umm... now in site_html_link.. you would put something like this (i think you should know where).."

Unfortunately, I can't figure out which file you mean...there's no site_html_link that I know of and I can't figure out which other file it might be.

Thanks again! Once it's worked out I'll try to post this thread to the resource center as a fix to the sorting...
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Never mind the last msg. Got it now. For people looking at this thread in the future, you have to remove the original mod's code from site_html_templates.pl

Where Jerry said "site_html_link" it means site_html_templates.pl...and it's to replace the original line where it said rate_img => etc...

Now I have to figure out why my sorting is messed up...I don't know if it's the logo priority mod, the image rating mod or external rate it mod! Whew, Mod Madness!

[This message has been edited by joegilbert (edited September 07, 1999).]
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
i would say priority mod... (cause it messes with the sorting.. [db_utils.pl - sub build_sorthit])

jerry
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Makes sense...but I had the logo mod installed and sorting right before starting the other mods...I wonder if it could be the combo of multi alt category mods with priority mod? Tomorrow I'll post the code for the sort routine, maybe you'll have a good hint for me as you did with the other thing. Cheers!
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Hmmm... works as advertised. Any ideas on how
to: 1) link to rate.cgi for individual link,
and 2) show Rating and Votes in ALT tag?
Neither $rec('ID') or $ID works in the
subroutine...
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
To be exact, you have to replace <%Rating%> to <%rate_img%> in link.html if using templates.
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
oldmoney,

1) You would have to edit the link.html file. You can add something like the following:

Code:
<a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate this Site</a>

2) To show Rating and Votes in the Alternative Text Representation attribute, the codes that Widgetz provided will do this:

Look at alt="$rating"...that adds the text representation to the image!

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Hello widgetz,

Code:
sub get_rating_image {
my ($rating) = @_;
my ($i, $image);
for ($i = 0; $i <= 20; $i++) {
$image = qq~<img src="$rating_images_url/rate$i.gif" width="94" height="20" alt="$rating" border="0">~ and last if ($rating <= $i/2);
}
return $image | | $rating;
}

is it possible to use this with only 5 images? Any ideas, cause I have problems with the mod by phoenix and want to use this shorter.

Regards, DelPierro

------------------
Simon Ballmann
webmaster@fussballsuche.de
www.fussballsuche.de
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Yea...what I have done is use the following image to number ratio:

image_1.gif = 1
image_1.gif = 2
image_1.gif = 3
image_1.gif = 4
image_2.gif = 5
image_2.gif = 6
image_2.gif = 7
image_2.gif = 8
image_3.gif = 9
image_3.gif = 10
image_3.gif = 11
image_3.gif = 12
image_4.gif = 13
image_4.gif = 14
image_4.gif = 15
image_4.gif = 16
image_5.gif = 17
image_5.gif = 18
image_5.gif = 19
image_5.gif = 20

This is a quick and dirty solution.

You could try hacking the codes Widgetz has provided in the following manner....

Change the following codes:

Code:
for ($i = 0; $i <= 20; $i++) {

to the following:

Code:
for ($i = 0; $i <= 5; $i++) {

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Thanks Eliot,

but it don't work.
Sometimes the images are shown, but not loaded, sometimes the images are not shown, than only the rating number is shown.

Is this a correct code?
Code:
~ and last if ($rating <= $i/2);

Regards

------------------
Simon Ballmann
webmaster@fussballsuche.de
www.fussballsuche.de
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Simon,

Which option didn't work? The quick and dirty or the code hack? Please be more specific.

And yes, you have the correct codes.

Best of luck!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Hello Eliot,

sorry I don't know what you mean with 'The quick and dirty or the code hack'.

Some images will be load, yet, some others not. I have the example here: http://www.fussballsuche.de/...ubs/Germany/League1/ (but only for 1 or 2 hours, cause it's a working site and in Germany it's late).

If you have some time, please have a look at and you would see the problem.

Regards Simon
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Hello again,

[qoute]If you have some time, please have a look at and you would see the problem.[/qoute]

otherwise I will post it again later.

And I have a second question, nobody can answered me in the 'Perl and CGI Forum' and think for you it's not a problem. Could you please help me again with this: http://www.gossamer-threads.com/...um8/HTML/001262.html

Regards, Simon
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Opps...I gave you the opposite scheme for the quick and dirty. You need to upload twenty images, but re-number them.

Like the following:

=====================
image1.gif

would also be

image2.gif
image3.gif
image4.gif

==================

image5.gif

would also be

image6.gif
image7.gif
image8.gif

================

image 9.gif

would also be

image10.gif
image11.gif
image12.gif

================

image13.gif

would also be

image14.gif
image15.gif
image16.gif

================

image17.gif

would also be

image18.gif
image19.gif
image20.gif

=====================

Sorry for the confusion.

If I get around to it, I will try to respond to your other Topic.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: ratings amazon-image-style mod problems In reply to
Hello Eliot,

now it works, thank's a lot. Smile

But it only works after I change the count number from '<= 5' to '<= 20'.
With a count number '<= 5' sometimes only the rating-number would be shown, sometimes an image.

Regards Simon

------------------
Simon Ballmann
webmaster@fussballsuche.de
www.fussballsuche.de
Quote Reply
Re: ratings amazon-image-style mod problems In reply to
You should use the original codes that Widgetz provided!

Use

Code:
for ($i = 0; $i <= 20; $i++) {

If you missed it, I gave you two mutually exclusive suggestions...mutually exclusive meaning don't apply both.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: ratings amazon-image-style mod problems In reply to
============================================
=My Ratings amazon-image-style (Five stars)=
============================================

- My Ratings amazon-image-style mod (Five stars)(no-templates)
Author : Eduin Yesid Carrillo (yecarrillo@hotmail.com)
URL : http://www.scoutsace.f2s.com/scripts
Thread : http://www.gossamer-threads.com/...um3/HTML/003069.html

- Thanks to:
widgetz : original mod :Ratings amazon-image-style


=====================================================
links/cgi-bin/admin/links.cfg
=====================================================
Change the following codes:

Code:
# PATH and URL of What's Rating page. No Trailing slash.
$build_ratings_path = "$build_root_path/ratings";
$build_ratings_url = "$build_root_url/ratings";
to the following(change "$build_root_url/images" to the proper
location of where your images will be):

Code:
# PATH and URL of What's Rating page. No Trailing slash.
$build_ratings_path = "$build_root_path/ratings";
$build_ratings_url = "$build_root_url/ratings";
$build_ratings_images_url = "$build_root_url/images";
=====================================================
links/cgi-bin/admin/site_html.pl
=====================================================

Add this to the end of site_html.pl just before
1; line.
Change the width and the height to the size yours is going to be..

Code:
##########################################################
## Ratings amazon-image-style
##########################################################

sub get_rating_image {
# --------------------------------------------------------
# My Ratings amazon-image-style mod (Five stars)(no-templates)
# Author : Eduin Yesid Carrillo (yecarrillo@hotmail.com)
#
my ($rating,$img) = @_;

my $img1 = int($rating/2);
my $img2 = $img1 + 1;

if ($img1 - ($rating/2) == 0 ) { $img = "$img1"; }
else { $img = "$img1-$img2";}

my $image = qq~<img src="$build_images_url/rate-$img.gif" width=65 height=12 alt="$rating" border="0">~;

return $image;
}
Now, change the following codes:

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) = @_;
to the following:

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) = @_;
$rate_img = (&get_rating_image($rec{'Rating'}));
Finally, place the image of each link:

Change the following codes (sub site_html_link):

Code:
$output .= qq~ <small class="date">(Added: $rec{'Date'} Hits: $rec{'Hits'} Rating: $rec{'Rating'} Votes: $rec{'Votes'}) <a href="$build_rate_url?ID=$rec{'ID'}">Rate It</a></small>
to the following:

Code:
if ($rec{'Rating'} ne 0) { $output .= qq~ $rate_img~; }
$output .= qq~ <small class="date">(Added: $rec{'Date'} Hits: $rec{'Hits'} Votes: $rec{'Votes'}) <a href="$build_rate_url?ID=$rec{'ID'}">Rate It</a></small>
You will need to rename your images to

rate-1.gif
rate-1-2.gif
rate-2.gif
rate-2-3.gif
rate-3.gif
rate-3-4.gif
rate-4.gif
rate-4-5.gif
rate-5.gif


ok.. that's all..


Quote Reply
Re: [widgetz] ratings amazon-image-style mod problems In reply to
$ratings has no value so $i=0, S how do I define $ratings since the only rate0.gif comes up when there is none, please help. I need to define $ratings.Frown
Quote Reply
Re: [LILHOMIE] ratings amazon-image-style mod problems In reply to
I'm not seeing a $ratings variable in the code, please be more specific with your problem...


Leonard
aka PerlFlunkie