NAME

HTML::Pager - Perl module to handle CGI HTML paging of arbitary data


SYNOPSIS

  use HTML::Pager;
  use CGI;
  # get CGI query object
  my $query = CGI->new();
  # create a callback subroutine to generate the data to be paged
  my $get_data_sub = sub {
     my ($offset, $rows) = @_;
     my @return_array;
     for (my $x = 0; $x < $rows; $x++) {
        push(@return_array, [ time() ]);
     }
     return \@return_array;
  }
  # create a Pager object 
  my $pager = HTML::Pager->new(
                               # required parameters
                               query => $query,
                               get_data_callback => $get_data_sub,
                               rows => 100,
                               page_size => 10,
                               # some optional parameters
                               persist_vars => ['myformvar1', 
                                                'myformvar2', 
                                                'myformvar3'],
                               cell_space_color => '#000000',    
                               cell_background_color => '#ffffff',
                               nav_background_color => '#dddddd',
                               javascript_presubmit => 'last_minute_javascript()',
                               debug => 1,
                              );
  # make it go - send the results to the browser.
  print $pager->output;


DESCRIPTION

This module handles the paging of data coming from an arbitrary source and being displayed using HTML::Template and CGI.pm. It provides an interface to pages of data similar to many well-known sites, like altavista.digital.com or www.google.com.

This module uses HTML::Template to do all its HTML generation. While it is possible to use this module without directly using HTML::Template, it's not very useful. Modification of the look-and-feel as well as the functionality of the resulting HTML should all be done through HTML::Template objects. Take a look at the HTML::Template manpage for more info.


METHODS

new()

The new() method creates a new Pager object and prepares the data for output().

new() requires several options, see above for syntax:

new() supports several optional arguements:

output()

This method returns the HTML <FORM> and <TABLE> to create the paging list-view. If you used the template option to new() this will output the entire template.


MAINTAINING PAGING STATE

Sometimes you'll want to be able to allow the user to leave your paging list and be able to come back to where they were without requiring that they use the Back button. To do this all you have to do is arrange to save the state of the PAGER_offset parameter, and pass it back to the paging-list CGI.


CREDITS

This module was created for Vanguard Media and I'd like to thank my boss, Jesse Erlbaum, for allowing me to release it to the public. He also added the persist_vars functionality, the background colors option and the javascript_presubmit option.


AUTHOR

Sam Tregar, sam@tregar.com


LICENSE

HTML::Template : A Perl module to handle CGI HTML paging of arbitary data Copyright (C) 1999 Sam Tregar (sam@tregar.com)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


SEE ALSO

the HTML::Template manpage, CGI