Just to tell you up front, I've never used HTML::Pager, but it looks easy enough, and I use HTML::Template regularly.

HTML::Pager only wants (in the end) the set of data to be displayed in the template. What I would do is get your @files array, then define the H::P callback function so it will only get extended info for the relevant items that are to be displayed on the page. Some code: (UNTESTED)

my $get_data_sub = sub { my ($offset, $rows) = @_; my @return_array; my $sth = $dbh->prepare('SELECT id, title FROM resource WHER +E id = ?'); for (my $x = 0; $x < $rows; $x++) { my $filename = substr($files[$offset + $x], 0, -4); $sth->execute($filename); # Note I assume that the ID is unique (no need for a while loo +p - only # one record will be returned) otherwise the paging really doe +sn't work. $ref = $sth->fetchrow_hashref(); push @return_array, { ID => $ref->{id}, TITLE => $ref->{title} }; $sth->finish; } return \@return_array; }

That's a start, anyway. You'll have to make your H::P template know that it has named vars for each line (TITLE and ID). I would also change the sub so that it takes more args (like the @items array and the $dbh database handler) so you don't have to reference global vars.

HTH

Update: Moved the $dbh->prepare(...) out of the loop.

--
"To err is human, but to really foul things up you need a computer." --Paul Ehrlich

In reply to Re: HTML::Template/Pager or both? by LTjake
in thread HTML::Template/Pager or both? by stew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.