NAME Template::Plugin::Page - a plugin to help when paging through sets of results 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 %] 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 [% page.first %] - [% page.last %] of [% page.total_entries %] records.
Page [% page.current_page %] of [% page.last_page %]
[% IF page.previous_page %] Previous [% END %]    [% IF page.next_page %] Next [% END %] ... which would output something like: Matches 121 - 130 of 134 records.
Page 13 of 14
Previous     Next Note that this module is simply a plugin to the Data::Page module. METHODS Page This is the constructor. It currently takes two mandatory arguments, the total number of entries and the number of entries per page. It also optionally takes the current page number (which defaults to 1). [% USE page = Page(total_entries, entries_per_page, current_page) %] [%# or #%] [% USE page = Page(134, 10) %] [%# or #%] [% USE page = Page(134, 10, 5) %] total_entries This method returns the total number of entries. Total entries: [% page.total_entries %] entries_per_page This method returns the total number of entries per page. Entries per page: [% page.entries_per_page %] current_page This method returns the current page number. Current page: [% page.current_page %] first_page This method returns the first page. This is put in for reasons of symmetry with last_page, as it always returns 1. Pages range from: [% page.first_page %] last_page This method returns the total number of pages of information. Pages range to: [% page.last_page %] first This method returns the number of the first entry on the current page. Showing entries from: [% $page.first %] last This method returns the number of the last entry on the current page. Showing entries to: [% page.last %] previous_page This method returns the previous page number, if one exists. Otherwise it returns undefined. Previous page number: [% page.previous_page %] next_page This method returns the next page number, if one exists. Otherwise it returns undefined. Previous page number: [% page.previous_page %] splice This method takes in an listref, and returns only the values which are on the current page. [% visible_holidays = page.splice(holidays) %] AUTHOR Leon Brocard, COPYRIGHT Copyright (C) 2000-2, Leon Brocard This module is free software; you can redistribute it or modify it under the same terms as Perl itself.