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

Help with new in category global

Quote Reply
Help with new in category global
Hello GT world,

I have done the best I could to come up with a solution to display new records in a category and it's subcats. I have been using this global. It's based on the full name of a category & usinf the SQL 'LIKE' command to compare. The only problem I have had so far, is when a copy the same record in several subcats. The global when then return several times in a row the same records ... Unsure Could some who speaks perl help me include a line that filters out duplicate ID's in the response. Thanks a lot Smile



sub {
my $tags = shift;
my $limit = ($tags->{Random_Limit} =~ /^(\d+)$/) ? $1 : 10;
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','Category');
$link_db->select_options ('ORDER BY ADD_DATE', ,'DESC', "LIMIT $limit");
my $condition = GT::SQL::Condition->new('Full_Name', 'LIKE', 'Still___Motion_Graphics/%','isNew', '=', 'Yes','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 } }
Subject Author Views Date
Thread Help with new in category global nt6 1712 Nov 5, 2002, 2:56 AM
Thread Re: [nt6] Help with new in category global
afinlr 1633 Nov 5, 2002, 8:59 AM
Thread Re: [afinlr] Help with new in category global
nt6 1632 Nov 5, 2002, 9:07 AM
Post Re: [nt6] Help with new in category global
afinlr 1626 Nov 5, 2002, 9:13 AM