I've just released a new version of Data::Page and seeing as a lot of
people have been bugging me about it recently I've also released
Template::Plugin::Page, which has just hit CPAN:
Template::Plugin::Page - a plugin to help when paging through sets of results
=head1 SYNOPSIS
[% USE page = Page($total_entries, $entries_per_page, $current_page) %]
First page: [% page.first_page %]
Last page: [% page.last_page %]
First entry on page: [% page.first %]
Last entry on page: [% page.last %]
=head1 DESCRIPTION
When searching through large amounts of data, it is often the case
that a result set is returned that is larger than we want to display
on one page. This results in wanting to page through various pages of
data. The maths behind this is unfortunately fiddly, hence this
module.
The main concept is that you pass in the number of total entries, the
number of entries per page, and the current page number. You can then
call methods to find out how many pages of information there are, and
what number the first and last entries on the current page really are.
It would be typically used in the following way for an HTML template:
[% USE page = Page(134, 10, 13) %]
Matches <b>[% page.first %] - [% page.last %]</b> of
<b>[% page.total_entries %]</b> records.<BR>
Page <b>[% page.current_page %]</b> of
<b>[% page.last_page %]</b><BR>
[% IF page.previous_page %]
<a href="index.cgi?page=[% page.previous_page %]">Previous</a>
[% END %]
[% IF page.next_page %]
<a href="index.cgi?page=[% page.next_page %]">Next</a>
[% END %]
... which would output something like:
Matches <b>121 - 130</b> of
<b>134</b> records.<BR>
Page <b>13</b> of
<b>14</b><BR>
<a href="index.cgi?page=12">Previous</a>
<a href="index.cgi?page=14">Next</a>
Note that this module is simply a plugin to the Data::Page module.
Leon
--
Leon Brocard.............................http://www.astray.com/
scribot.................................http://www.scribot.com/
... Drive C: Error, (A)bort (R)etry (I)gnore (K)ick (S)cream
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates