Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Total New Links Specific by Category

Quote Reply
Total New Links Specific by Category
Hi,

How to show the total of new links based on specific category? Currently i'm using the tag below to show overall total link:

Code:
totalnew:
sub {
$DB->table('Links')->count( { isNew => 'Yes' } )
}

I think its maybe something it can be done by using tag below:

Code:
lastlinks:
sub {
my ($all_ids,@list);
my $cat_id = '243';
$all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids, $cat_id;
my $link_db = $DB->table('Links','CatLinks','Category');
$link_db->select_options ("ORDER BY Add_Date DESC LIMIT 10");
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', \@$all_ids);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 36) {
$link->{Title} = substr($link->{Title}, 0, 36) . '...';
}
push @list, $link;
}
my $output;
foreach my $link (@list) {
# Set the category url
my $url = $DB->table('Category')->as_url($link->{'Full_Name'});
# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$link->{'LinkID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display ('lastlinks', $link);
}
return $output;
}

Please help.

Last edited by:

reenee: May 24, 2003, 10:25 AM
Quote Reply
Re: [reenee] Total New Links Specific by Category In reply to
I think its something like this

Code:


sub {
my ($all_ids);
my $cat_id = shift;
$all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids,$cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','isNew'='Yes','CategoryID', 'IN', \@$all_ids);
my $count = $link_db->count($condition);

return $count;
}


Laura.

The UK High Street
Quote Reply
Re: [afinlr] Total New Links Specific by Category In reply to
Hi Afinlr,

Thank you so much,

I fix your tag with:

sub {
my ($all_ids);
my $cat_id = shift;
$all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids,$cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','isNew','=','Yes','CategoryID', 'IN', \@$all_ids);
my $count = $link_db->count($condition);

return $count;
}



Thanks again
Quote Reply
Re: [reenee] Total New Links Specific by Category In reply to
Glad it worked - can't quite see what the difference is in your global?

Before Paul corrects me again, you don't need \@$all_ids in the condition statement - you can change it to $all_ids

Laura.
Quote Reply
Re: [afinlr] Total New Links Specific by Category In reply to
Hi, I am very much intrested in this global, can someone please be kind to post the hole/complete script since I am not "Perl" wise!

Thanks in advance