Hi All,
I have the following global that I'm using on the category template to bring back x number of links from all the subcategories (I have it set to 40), this works fine, however I want to set the script to bring back 5 links from each category.
my $tags = shift;
my $cat = $tags->{'Full_Name'};
my $output;
my $sth;
my $link;
use GT::SQL::Condition;
my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('GROUP BY LinkID ORDER BY Add_Date DESC Limit 40');
$sth = $search_db->select (['Links.ID', 'Links.Description', 'Links.Title', 'Links.Add_Date', 'Category.Full_Name', 'Category.Name', 'Links.Hits'], GT::SQL::Condition->new(['Full_Name', 'LIKE', $cat .'%'], ['isValidated', '=', 'Yes']));
while ($link = $sth->fetchrow_hashref)
{
# Set the category url
my $category_url = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
# Set the detailed_url
my $detailed_url = $CFG->{db_cgi_url}."/jump.cgi?ID=".$link->{'ID'};
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Anyone have any ideas?
Thanks!
George
I have the following global that I'm using on the category template to bring back x number of links from all the subcategories (I have it set to 40), this works fine, however I want to set the script to bring back 5 links from each category.
Code:
sub { my $tags = shift;
my $cat = $tags->{'Full_Name'};
my $output;
my $sth;
my $link;
use GT::SQL::Condition;
my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('GROUP BY LinkID ORDER BY Add_Date DESC Limit 40');
$sth = $search_db->select (['Links.ID', 'Links.Description', 'Links.Title', 'Links.Add_Date', 'Category.Full_Name', 'Category.Name', 'Links.Hits'], GT::SQL::Condition->new(['Full_Name', 'LIKE', $cat .'%'], ['isValidated', '=', 'Yes']));
while ($link = $sth->fetchrow_hashref)
{
# Set the category url
my $category_url = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
# Set the detailed_url
my $detailed_url = $CFG->{db_cgi_url}."/jump.cgi?ID=".$link->{'ID'};
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Thanks!
George