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

last links of a category from the detailed page

Quote Reply
last links of a category from the detailed page
I

I use the following global to display the links from a category in the detailed page

sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options("ORDER BY $CFG->{build_sort_order_category}");
my $sth = $link_db->select({ CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}


It works fine but I would like 3 more things :
- I only want to display the last five links added of the specified category
- I just want to display the validated links
- In the last links, I don't want to see the link of the detailed link page


Txs for your help
regards
FMPWink
Quote Reply
Re: [fmp] last links of a category from the detailed page In reply to
Ok, assuming the larger the ID the newer the link, you need to create a condition object.

Quote:
my $cond = GT::SQL::Condition->new (
'Links.isValidated', '=', 'Yes',
'Links.ID', '!=', $tags->{'ID'},
'Category.CategoryID', '=', $cat_id,
);
$cond->bool('AND');
$link_db->select_options("ORDER BY Link.ID DESC", "Limit 5" );
my $sth = $link_db->select( $cond );


All I can say is give this a try. <G> It sets up a condition object, for your expressed conditions, and a select_options for how you want it ordered. If you want the LAST FIVE links, ordering by category order is not really how you want to do it....


Not sure how it works with joined tables, but it should....


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.