Gossamer Forum
Quote Reply
Most popular links
Hi,

I am using the below global to display the 5 most popular links based on Hits which works fine.

My question is how can I modify it to only include links that have:

1. Add_Date equal to today
2. isNew = "Yes"

The two should of course not be combined - ie. two different globals.

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

Cheers
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Most popular links In reply to
Maybe something like this;

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

... and for the second one, maybe something like;

Code:
sub {
my $tags = shift;
my $date = GT::Date::date_get();
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', 'LIMIT 5');
my $sth = $table->select( { Add_Date => $date } );
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top5_loop => \@output };
}

Both are untested, but should work.

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 popular links In reply to
...as long as you change:

isValidated

to

isNew Cool
Quote Reply
Re: [Paul] Most popular links In reply to
Whoops....my boo-boo :p Too early in the morning.

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 popular links In reply to
Thanks Andy....

Klaus

http://www.ameinfo.com