I initially started to use HTML::Pager, but have sinced moved on to
Data::Page.
cgiapp runmode code:
sub screen_applicants {
my $self = shift;
my $query = $self->query;
my $unscreened_iterator = RF::CDBI::Subscribers->search( 'screened'
=> 0 );
my $unscreened = [];
my $total = $unscreened_iterator->count;
my $current_page = $query->param( 'page' ) || 1;
my $page_info = Data::Pageset->new( {
'total_entries' => $total,
'entries_per_page' => 30,
'current_page' => $current_page,
} );
# Now page_info can give me the slice to get...
my $page_slice = $unscreened_iterator->slice( $page_info->first-1,
$page_info->last );
while( my $subscriber = $page_slice->next ) {
my $sub_hash = $subscriber->tmpl_hash;
push @$unscreened, $sub_hash;
}
my $template = $self->load_tmpl(
'rf_screen_applicants.TMPL',
'die_on_bad_params' => 0,
);
$template->param(
'the_unscreened' => $unscreened,
'page' => $current_page,
);
if ( $page_info->last_page > 1 ) {
my $pages = [];
foreach my $page ( @{$page_info->pages_in_set()} ) {
my $current = ( $page == $page_info->current_page() ) ? 1 : 0;
push @$pages, {
'page' => $page,
'current' => $current,
};
}
$template->param(
'multiple_pages' => 1,
'pages' => $pages,
);
}
$template->output;
}
html template code:
...
<!-- TMPL_IF NAME="multiple_pages" -->
<div id="pagenav">
<!-- TMPL_LOOP NAME="pages" -->
<!-- TMPL_IF NAME="current" -->
<B><!-- TMPL_VAR NAME="page" --></B>
<!-- TMPL_ELSE -->
<A HREF="rfadmin.cgi?page=<!-- TMPL_VAR NAME="page" -->"><!--
TMPL_VAR NAME="page" --></A>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</div>
<!-- /TMPL_IF -->
...
HTH & Have Fun!
- Jason
Webmaster Techcode.NET wrote:
Just wondering - is there a module that would help with pagination of data
returned by a search.
Hopefuly - there is something that works with HTML::Template.
BTW. I can't access the www.cgi-app.org ?
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]