Gossamer Forum
Home : Products : Links 2.0 : Customization :

Paul Wilson's 5-star mod

Quote Reply
Paul Wilson's 5-star mod
Hi Paul,

Just got your 5Star rating and before implementing it, got a question regarding the code:


$rating = qq|<img src="$build_root_url/images/clr.gif">| x '5' if ($rec{'Rating'} =~ /(9|10)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(7|8)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(5|6)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(3|4)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(1|2)(\.\d\d)?/);


Code appears identical for all the lines except the first. Shouldn't the '4' be '3','2' and '1' for all the rest? In other words, isn't " | x '5' " the line that determines how many times the graphic is repeated?


Like this?


$rating = qq|<img src="$build_root_url/images/clr.gif">| x '5' if ($rec{'Rating'} =~ /(9|10)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '4' if ($rec{'Rating'} =~ /(7|8)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '3' if ($rec{'Rating'} =~ /(5|6)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '2' if ($rec{'Rating'} =~ /(3|4)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/images/clr.gif">| x '1' if ($rec{'Rating'} =~ /(1|2)(\.\d\d)?/);

Thanks!



Quote Reply
Re: Paul Wilson's 5-star mod In reply to
Additionally, there seems to be another problem, and it's the fact that I just rated a new site with 10 (so Rating=10, Votes=1), but the 1-star image option appears instead of the 5-star expected!

Check it out:

http://cgi.webcamworld.com/...cgi?query=antarctica

Thanks!


Quote Reply
Re: Paul Wilson's 5-star mod In reply to
Yet another weird example:

Site has 18 votes and a rating of 8.35, however only 2 stars are displayed:

http://cgi.webcamworld.com/...h.cgi?query=le+monde

Ideas?

Thanks!


Quote Reply
Re: Paul Wilson's 5-star mod In reply to
Ooo wonder how that got in there.

I re-wrote it a week or two ago and thought I'd updated the zip but looks like I updated it with some code that someone else tried to use....duh

I'll update the zip today.

Mods:http://wiredon.net/gt/download.shtml
Installations:http://wiredon.net/gt/
Quote Reply
Re: Paul Wilson's 5-star mod In reply to
I tried both options and the second one is the one that produces the weird behaviour. Leaving aside the 'x 4' stuff, what else can be happening?

Why the display is not accurate? Has decimal point anything to do with this? Is there any ABSolute function that would pick just the left most number?

Thanks!


Quote Reply
Re: Paul Wilson's 5-star mod In reply to
TO whom it may concern,

I switched to Widgetz mod to display the rating images...

Thanks.

Quote Reply
Re: [webcamworld] Paul Wilson's 5-star mod In reply to
Same problem here... is this Mod actually any good ?
Where is "widgetz" mod ?
Quote Reply
Re: [webcamworld] Paul Wilson's 5-star mod In reply to
Quote:
Why the display is not accurate? Has decimal
point anything to do with this? Is there any
ABSolute function that would pick just the left most
number?

Yeah... the decimal point has got to be the problem...

I modified the code as follows, and got the "1" and "10" ratings to work
by adding 1.00 and 10.00:
Code:
sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like with 5 start mod.

my %rec = @_;

$rating = qq|<img src="$build_root_url/graphics/tools/clr.gif">|
x '5' if ($rec{'Rating'} =~ /(9|10.00)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/graphics/tools/clr.gif">|
x '4' if ($rec{'Rating'} =~ /(7|8)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/graphics/tools/clr.gif">|
x '3' if ($rec{'Rating'} =~ /(5|6)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/graphics/tools/clr.gif">|
x '2' if ($rec{'Rating'} =~ /(3|4)(\.\d\d)?/);
$rating = qq|<img src="$build_root_url/graphics/tools/clr.gif">|
x '1' if ($rec{'Rating'} =~ /(1.00|2)(\.\d\d)?/);
$rating = qq|<small> no rating</small>| if ($rec{'Rating'} < 1);

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) :
(delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) :
(delete $rec{'isPopular'});

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

BUT when "decimals" are involved it gets "weird?!?"

See it here:http://www.nuzgeeks.com/...ks/pages/Television/

I've tried every other combination I can think of... but I'm not a coder... ANY IDEAS ?
I downloaded the zip today 10/6/01
so it was never fixed by its creator Unsure




Last edited by:

Patricio: Oct 6, 2001, 10:40 PM
Quote Reply
Re: [RedRum] Paul Wilson's 5-star mod In reply to
RedRum... are you out there ?
Quote Reply
Re: [Patricio] Paul Wilson's 5-star mod In reply to
Hi,

Whoops, sorry. I could have sworn I updated it......hmmmm.....will do it now - I'll re-post here whem I'm done.
Quote Reply
Re: [Patricio] Paul Wilson's 5-star mod In reply to
Hi,

Ok it's updated.
Quote Reply
Re: [RedRum] Paul Wilson's 5-star mod In reply to
RedRum...
Nope...still not working...Crazy
See it here... it's even wierder...?!?!?

This one prints "No Rating" and bunch of starts, even same # for rating "1" "5" "9" !?!?!?
http://www.nuzgeeks.com/...Tools_%26_Resources/

This one... also has ratings, but still prints "No Rating" and whatever stars it comes up with...
http://www.nuzgeeks.com/...ks/pages/Television/


Quote Reply
Re: [RedRum] Paul Wilson's 5-star mod In reply to
FIXED !! I think..!?!?Crazy

Code:
$rating .= qq|<img src="$build_root_url/images/clr.gif">
| x int(($rec{'Rating'}/2) + .5);
$rating = qq|<small>No Rating
</small>| if ($rec{'Rating'} < 1);

Noticed the " . "before the " = "
Code:
$rating .=
when I take it out it seems to work...!?!? but I left it
untouched for you to see how it is acting up.

Is that it ? just remove the " . "???

Could you explain how "the math" works...??
Sure like to learn.

Thank you for your help Smile

Last edited by:

Patricio: Oct 7, 2001, 12:58 PM
Quote Reply
Re: [Patricio] Paul Wilson's 5-star mod In reply to
I tested it before updating the zip and it seemed to work with the . but if it doesn't work for you then take it out - it shouldn't really be there anyway.

Re the math:

It takes the rating and divides it by 2 and adds .5 and rounds it off to an integer.

Last edited by:

RedRum: Oct 7, 2001, 1:17 PM
Quote Reply
Re: [RedRum] Paul Wilson's 5-star mod In reply to
Thank you "RedRum"

So far... it definitely works without the " . "
Thank you for a great mod.
As requested, I will include a link to you in my search results page at http://www.nuzgeeks.com

Pat
ps: where can I find a descriptions to your mods ?