Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How can I do 1-10 half star ratings?

Quote Reply
How can I do 1-10 half star ratings?
HI,

I thought I had seen a public mod to add star ratings, but can't seem to find it via search. What I'd like to do is have stars and half star icons for the user 1-10 link ratings. Anyone accomplished this with links???

Thanks!
Quote Reply
Re: [Jonze] How can I do 1-10 half star ratings? In reply to
Hi,

Do you mean 1-5 stars, but with 1/2 's ? ( i.e 1/2 star, 1 star, 1 1/2 stars, 2 stars , up to 5 full stars)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How can I do 1-10 half star ratings? In reply to
Hey Andy,

Yes sir, exactly that.
Quote Reply
Re: [Jonze] How can I do 1-10 half star ratings? In reply to
Hi,

You could try this : (untested, but should work =))

new global: get_star_rating

Code:
sub {

my $avg2 = $_[0];
my $rate_img;
if ($avg2 == 0) {
$rate_img = '0';
} elsif ($avg2 > 1 && $avg2 <= 2) {
$rate_img = '1';
} elsif ($avg2 > 2 && $avg2 <= 3) {
$rate_img = '2';
} elsif ($avg2 > 3 && $avg2 <= 4) {
$rate_img = '3';
} elsif ($avg2 > 4 && $avg2 <= 5) {
$rate_img = '4';
} elsif ($avg2 > 5 && $avg2 <= 6) {
$rate_img = '5';
} elsif ($avg2 > 6 && $avg2 <= 7) {
$rate_img = '6';
} elsif ($avg2 > 7 && $avg2 <= 8) {
$rate_img = '7';
} elsif ($avg2 > 8 && $avg2 <= 9) {
$rate_img = '8';
} elsif ($avg2 > 9 && $avg2 <= 10) {
$rate_img = '9';
} elsif ($avg2 == 10) {
$rate_img = '10';
}

return q|stars-10-| . $rate_img . q|.gif|;

}

Call with:

Code:
<%set star_num = get_star_rating($Rating)%>
<%Links::Utils::image_url($star_num)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!