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 } }
Quote Reply
Re: [nt6] Help with new in category global In reply to
Try this old post from Paul

http://www.gossamer-threads.com/...i?post=188796#188796
Quote Reply
Re: [afinlr] Help with new in category global In reply to
That is a five page post, could you be more specific please? Smile
Quote Reply
Re: [nt6] Help with new in category global In reply to
The link I gave you should go straight to the relevant message.