Hi,
Something like this should work:
my $cat = $_[0];
my ($output,$sth,$link);
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 10');
$sth = $search_db->select ( ['Links.*'], GT::SQL::Condition->new(['CategoryID', 'IN', $all_ids], ['isValidated', '=', 'Yes', 'isNew', '=', 'Yes']) );
my $seen;
my $output;
my @loop;
while ($link = $sth->fetchrow_hashref) {
if ($seen->{$link->{ID}}) { next }
$link->{category_url} = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
$link->{detailed_url} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
#$output .= Links::SiteHTML::display('sortlink', $link);
$seen->{$link->{ID}} = 1;
push @loop, $link;
}
return { new_loop => \@loop, rows => $sth->rows };
}
Call with:
<%loop new_loop%>
<%inlcude sortlink.html%>
<%endloop%>
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!
Something like this should work:
Code:
sub { my $cat = $_[0];
my ($output,$sth,$link);
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 10');
$sth = $search_db->select ( ['Links.*'], GT::SQL::Condition->new(['CategoryID', 'IN', $all_ids], ['isValidated', '=', 'Yes', 'isNew', '=', 'Yes']) );
my $seen;
my $output;
my @loop;
while ($link = $sth->fetchrow_hashref) {
if ($seen->{$link->{ID}}) { next }
$link->{category_url} = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
$link->{detailed_url} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
#$output .= Links::SiteHTML::display('sortlink', $link);
$seen->{$link->{ID}} = 1;
push @loop, $link;
}
return { new_loop => \@loop, rows => $sth->rows };
}
Call with:
Code:
<%global_name%> <%loop new_loop%>
<%inlcude sortlink.html%>
<%endloop%>
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!