Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Add review rating to link.html

Quote Reply
Add review rating to link.html
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?
Quote Reply
Re: [MJB] Add review rating to link.html In reply to
You need a global for that I think.

Try this:
http://www.gossamer-threads.com/...i?post=233569#233569
Quote Reply
Re: [afinlr] Add review rating to link.html In reply to
I tried the first global:

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?
Quote Reply
Re: [MJB] Add review rating to link.html In reply to
Erm, I'm assuming you have it setup as you posted =)

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);
}

Wink

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] Add review rating to link.html In reply to
Cool Thanks.