I have added "Reviews: 0" to the "Ratings / Votes" count for each link (not detailed pages). How do I add "Reviews Rating: x" to the link?
Dec 15, 2005, 3:22 PM
Veteran (1921 posts)
Dec 15, 2005, 3:22 PM
Post #2 of 5
Views: 3085
You need a global for that I think.
Try this:
http://www.gossamer-threads.com/...i?post=233569#233569
Try this:
http://www.gossamer-threads.com/...i?post=233569#233569
Dec 16, 2005, 1:29 AM
Enthusiast (559 posts)
Dec 16, 2005, 1:29 AM
Post #3 of 5
Views: 3083
I tried the first global:
my $id = shift;
my ($avg) = $DB->table('Reviews')->select( 'AVG(Review_Rating)', { Review_LinkID => $id })->fetchrow_array;
$avg ||= 0;
return sprintf("%.2f", $avg);
}
but it returns the message "Error: Variable 'average_rating' is not a code reference". What does that mean?
Code:
average_rating => sub { my $id = shift;
my ($avg) = $DB->table('Reviews')->select( 'AVG(Review_Rating)', { Review_LinkID => $id })->fetchrow_array;
$avg ||= 0;
return sprintf("%.2f", $avg);
}
but it returns the message "Error: Variable 'average_rating' is not a code reference". What does that mean?
Dec 16, 2005, 2:04 AM
Veteran / Moderator (18441 posts)
Dec 16, 2005, 2:04 AM
Post #4 of 5
Views: 3084
Erm, I'm assuming you have it setup as you posted =)
You need;
Global name: average_rating
Value:
my $id = shift;
my ($avg) = $DB->table('Reviews')->select( 'AVG(Review_Rating)', { Review_LinkID => $id })->fetchrow_array;
$avg ||= 0;
return sprintf("%.2f", $avg);
}
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!
You need;
Global name: average_rating
Value:
Code:
sub { my $id = shift;
my ($avg) = $DB->table('Reviews')->select( 'AVG(Review_Rating)', { Review_LinkID => $id })->fetchrow_array;
$avg ||= 0;
return sprintf("%.2f", $avg);
}
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!