Hello,
here is the code I use to pull out the links with the most visits and display them on the frontpage:
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display ('linkshort', $link);
}
return $output;
}
The code is great, and all I would like to add, is the ability to specify from which categories to pull the links from, so links from unwanted categories will not appear.
Thanks in advance,
Brakkar
here is the code I use to pull out the links with the most visits and display them on the frontpage:
Code:
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display ('linkshort', $link);
}
return $output;
}
The code is great, and all I would like to add, is the ability to specify from which categories to pull the links from, so links from unwanted categories will not appear.
Thanks in advance,
Brakkar