Gossamer Forum
Quote Reply
Limit Links help
Heya all,

This has been frustrating me all morning... I'm trying to grab the X most recent links (wow, like that's never been done before!) but want to pass the number of links to return from the template. I have:

Code:
sub {
my ($output,$sth,$link);
my $limit = shift;
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Add_Date DESC","LIMIT $limit");
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('link_new_list', $link);
}
return $output;
}

I call it with: <%globalname('X')%> and I get: Can't call method "fetchrow_hashref" on an undefined value at (eval 1012) line 7.

If I hard-code $limit in the global it works fine. What am I missing?

Safe swoops
Sangiro

Last edited by:

sangiro: Jul 24, 2006, 4:00 AM
Subject Author Views Date
Thread Limit Links help sangiro 2231 Jul 24, 2006, 4:00 AM
Thread Re: [sangiro] Limit Links help
brewt 2114 Jul 24, 2006, 12:32 PM
Post Re: [brewt] Limit Links help
sangiro 2081 Jul 25, 2006, 4:36 AM