Gossamer Forum
Quote Reply
most helpful reviews
Hi Andy,
I thought there was a global for the 10 most helpful reviews?
But I can not find it anymore.

Do you have an idea or do you have an global for it?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
No globals I've written to do that (or at least I don't remember them =))

In Review_WasHelpful , do you just see 1/0, or does that go up every single time someone rates a review as helpful? If it does up, then should be pretty simple to make it so that a global can get the xx "most helpful" reviews :)

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] most helpful reviews In reply to
It shows for example
Review_WasHelpful 6
and
Review_WasNotHelpful 2

but I think it's not enough to count only Review_WasHelpful

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
Here's a starting point that you might be able to adapt:

Tag:

Code:
top_reviews

Global:

Code:
sub {
my $tags = shift;
my $table = $DB->table('Links','Reviews');
$table->select_options ('ORDER BY Review_WasHelpful DESC', 'LIMIT 10');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top_reviews_loop => \@output };
}

Call with:

Code:
<%top_reviews%>
<%loop top_reviews_loop%>
<%Title%>: <%Review_WasHelpful%><br>
<%endloop%>
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
Matthias70 wrote:
It shows for example
Review_WasHelpful 6
and
Review_WasNotHelpful 2

but I think it's not enough to count only Review_WasHelpful

Hi,

MJB's post is on the right track :)

Not sure what else you could dso really?

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] most helpful reviews In reply to
Hi MJB and Andy,
thanks for the global.
But should'nt it be the difference
Review_WasHelpful - Review_WasNotHelpful
Otherwise 6-6 would be a better review than 3-0

Do you understand what I mean.

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
Hi,

True - but not sure how simple that is to do in a SQL query =) Would probably need a script to do that - something like:

1) Add a new field to the reviews, called "OverallWasHelpful" (INT)

2) Add a script called "update_reviews_helpful.cgi" ... with this code:

Code:
#!/usr/local/bin/perl

use strict;
use lib '/your/path/to/admin';
use Links qw/$IN $DB $CFG/;
use CGI::Carp qw(fatalsToBrowser);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/your/path/to/admin');

$DB->table('Reviews')->update(
OverallWasHelpful => \"Review_WasNotHelpful - Review_WasHelpful"
)


Finally, run it from SSH to do the update. Then check the reviews, to see if the new OverallWasHelpful column was updated ok. If it was, you should be able to use this in the above global that MJB provided Smile

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] most helpful reviews In reply to
Hi Andy,
thanks for your idea. But a new field and a script is too much effort...

I thought it could be as easy to get the difference as the date difference in this global

I will first try MJBs global and in case the output is very strange I will try your idea.

Thanks again

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
Hi,

Yeah, that global wouldn't work - to get accurate results, you would definatly need to use a new script (the one above)

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] most helpful reviews In reply to
Hi Andy,
I just added this to MJBs global, but I'm getting an error.
Can you please have a look at it?

Code:
sub {
my $tags = shift;
my $table = $DB->table('Links','Reviews');
$table->select_options ('ORDER BY Review_WasHelpful DESC', 'LIMIT 5');
$sth = $search_db->select ( { isValidated => "Yes" } , { Review_Validated => 'Yes' });
while (my $link = $sth->fetchrow_hashref()) {
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top_reviews_loop => \@output };
}

Unable to compile 'top_reviews': Global symbol "$sth" requires explicit package name at (eval 41) line 5. Global symbol "$search_db" requires explicit package name at (eval 41) line 5. Global symbol "$sth" requires explicit package name at (eval 41) line 6. Global symbol "$sth" requires explicit package name at (eval 41) line 8. Missing right curly or square bracket at (eval 41) line 12, at end of line syntax error at (eval 41) line 12, at EOF

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
The error gives it away :)

$sth = $search_db->select ( { isValidated => "Yes" } , { Review_Validated => 'Yes' });

..should be:

my $sth = $search_db->select ( { isValidated => "Yes" } , { Review_Validated => 'Yes' });

That should hopefully sort it.

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] most helpful reviews In reply to
The rror message is getting shorter
but still there Wink

Unable to compile 'top_reviews': Global symbol "$search_db" requires explicit package name at (eval 41) line 5. Missing right curly or square bracket at (eval 41) line 12, at end of line syntax error at (eval 41) line 12, at EOF

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] most helpful reviews In reply to
Did you just cut and paste bits of globals? Tongue You have 2 different while() statements, but only one "select" and only one closing tag ;)

Try this:

Code:
sub {
my $tags = shift;
my $table = $DB->table('Links','Reviews');
$table->select_options ('ORDER BY Review_WasHelpful DESC', 'LIMIT 5');
my $sth = $table->select ( { isValidated => "Yes" } , { Review_Validated => 'Yes' });

my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top_reviews_loop => \@output };
}

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] most helpful reviews In reply to
Andy wrote:
Did you just cut and paste bits of globals? Tongue You have 2 different while() statements, but only one "select" and only one closing tag ;)


Hi Andy,
don't ask me. When I'm experimenting with globals I do not really know what I do Blush
Glad that it's working know.
Thanks

Matthias
gpaed.de

Last edited by:

Matthias70: Jul 6, 2010, 2:46 PM