OK, I found another thread with similar code that works good.
But can this global be changed to allow a category and all subcategories below it to be listed from.
As it is you pass in individual categories like:
page.cgi?p=include&Random_CatID=6&Random_CatID=7
sub {
my $tags = shift;
my $limit = ($tags->{Random_Limit} =~ /^(\d+)$/) ? $1 : 3;
my @parents = $IN->param('Random_CatID');
my @cat_ids;
foreach my $id (@parents) {
push @cat_ids, $id, $DB->table('Category')->children($id);
}
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
my $condition = GT::SQL::Condition->new( 'Description', 'IS NOT', \'NULL','isValidated','=','Yes');
if (@cat_ids) {
$condition->add('CategoryID', 'IN', \@cat_ids);
}
my $sth = $link_db->select($condition);
my @output;
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Random_Loop => \@output }
}
--------------------------------
Privacy Software