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

toolbar problems (GT::SQL::Display::HTML::Table)

Quote Reply
toolbar problems (GT::SQL::Display::HTML::Table)
Is anyone else experiencing a problem with plugins not being able to access the GT::SQL::Display::HTML::Table->toolbar method?

Here's an example from one of the sample Gossamer plugins that doesn't seem to work either:

Code:
use Links qw/$IN $DB $CFG/;

my $db = $DB->table('SearchLog');
my $nh = $IN->param('nh') || 1;
my $mh = $IN->param('mh') || 5;
my $sth = $db->query_sth ($IN);
my $hits = $sth->rows;
my $tb = $DB->html($db,$IN)->toolbar ($nh, $mh, $hits, $IN->url);
It appears that $tb is always empty, no matter how many pages of results there are to display.

When calling admin.cgi, if I specify nh=2, it will display the second page, and nh=3 displays the third, but it will never display the toolbar.

I last played with this back in the Alpha days, but I'm pretty sure that this is the same code which worked back then. Can anyone point me in the right direction here, I've been staring at it for a while now and I'm stumped.

Thanks in advance,
-Steven



Quote Reply
Re: toolbar problems (GT::SQL::Display::HTML::Table) In reply to
Hi,

The problem is with:

Code:
my $hits = $sth->rows;
The ->rows() method returns the actual number of rows fetched, not the total number of results the query would have matched. For instance in the search logger, when you get the first page of results, ->rows() only returns 5. Since you pass this into the toolbar, it thinks there are no more results.

What it should say is:

Code:
my $hits = $db->hits;
Hits returns the actual count of rows that would have been returned if we hadn't limited the results.

I'll fix up the SearchLogger! Thanks!

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: toolbar problems (GT::SQL::Display::HTML::Table) In reply to
In Reply To:
The problem is with:
my $hits = $sth->rows;

What it should say is:
my $hits = $db->hits;
Thanks Alex, that fixed the problem.

-Steven