I have the following global which works great to show the top 5 latest links on my homepage, and restricted to a certain length. I was wondering how I can amend this to only include links from a certain category, for example, only links from category with ID 500.
Thanks!
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY ID DESC Limit 5');
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 31) {
$link->{Title} = substr($link->{Title}, 0, 28) . '...';
}
$output .= Links::SiteHTML::display ('link4', $link);
}
return $output;
}
Thanks!
Code:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY ID DESC Limit 5');
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 31) {
$link->{Title} = substr($link->{Title}, 0, 28) . '...';
}
$output .= Links::SiteHTML::display ('link4', $link);
}
return $output;
}