Gossamer Forum
Quote Reply
editor monitor mod

the following paste is from the Editor Monitor plugin:


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.

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

Try changing;

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


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

Hope that helps.


Andy (mod)
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!