Gossamer Forum
Quote Reply
editor monitor mod
Hello,

the following paste is from the Editor Monitor plugin:

Code:

sub new_in_cat {
# -------------------------------------------------------------------
# Called with <%Plugins::ToolBox::new_in_cat($ID, 'Number of Links')%>
# Thanks Clint

my $cat_id = shift;
my $linklimit = shift;
if ($linklimit < 1) { $linklimit = 1; }
my $ct = $DB->table('Category');
my $lt = $DB->table ('Links');
my $children = $ct->children($cat_id);
#ensure current category is included in the list
push @$children, $cat_id;

my $number_of_children = @$children;

my $relation = $DB->table ('Links', 'CatLinks', 'Category');
$relation->select_options("ORDER BY ADD_DATE DESC", "LIMIT $linklimit" );
my $sth = $relation->select( 'Links.ID', { 'Category.ID' => $children }, GT::SQL::Condition->new('isNew', '=', 'Yes') );
my $topcount;
my $output;
while (my $linkID = $sth->fetchrow_array) {
my $title = $lt->select( ('Title'),{'ID' => $linkID } )->fetchrow_array;
$output .= qq~<li class="catlinks"><a href="$CFG->{db_cgi_url}/detail.cgi?ID=$linkID">$title</a></li>~;
}
#my $output = qq~<a href="$CFG->{build_detail_url}/$linkID$CFG->{build_extension}">$title</a>~;
return $output;
}


# Always end with a 1.
1;



I would think that this could be optimized to only return values that are validated. What do I need to add so that isValidated="yes" is added into the conditions?


Thank you and sorry for having no clue in Perl.
Quote Reply
Re: [nt6] editor monitor mod In reply to
Hi,

Try changing;

Code:
my $sth = $relation->select( 'Links.ID', { 'Category.ID' => $children }, GT::SQL::Condition->new('isNew', '=', 'Yes') );

...to;

Code:
my $cond = new GT::SQL::Condition;
$cond->add('isNew', '=', 'Yes');
$cond->add('isValidated', '=', 'Yes');
$cond->bool('AND');
my $sth = $relation->select( 'Links.ID', { 'Category.ID' => $children }, $cond );

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates