Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

X Number of links from each sub category on the category page.

Quote Reply
X Number of links from each sub category on the category page.
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.
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;
}
Anyone have any ideas?

Thanks!
George
Subject Author Views Date
Thread X Number of links from each sub category on the category page. macbethgr 6619 Mar 5, 2015, 11:17 AM
Thread Re: [macbethgr] X Number of links from each sub category on the category page.
tandat 6485 Mar 5, 2015, 4:55 PM
Thread Re: [tandat] X Number of links from each sub category on the category page.
macbethgr 6483 Mar 5, 2015, 5:56 PM
Thread Re: [macbethgr] X Number of links from each sub category on the category page.
tandat 6480 Mar 5, 2015, 6:07 PM
Post Re: [tandat] X Number of links from each sub category on the category page.
macbethgr 6476 Mar 5, 2015, 6:42 PM
Thread Re: [macbethgr] X Number of links from each sub category on the category page.
Andy 6465 Mar 6, 2015, 12:16 AM
Post Re: [Andy] X Number of links from each sub category on the category page.
macbethgr 6439 Mar 6, 2015, 6:11 PM