pager

This controls the pager display at the bottom (by default) of the list and search views. It expects a pager template argument which responds to the Data::Page interface.

</%doc>

<p class="pager">Pages: % foreach my $page ( $begin_page .. $end_page ) { % if ( $page == $pager->current_page ) { <span class="current-page"><% $page %></span> % } else { <& .page_link, page => $page &> % } % } </p>

% # -------------------------------------------------------------------------- <%init> our $pager; return unless $pager; # and ( $pager->first_page != $pager->last_page );

my $begin_page = $pager->current_page - 10;
$begin_page = $pager->first_page if $begin_page < 1;

my $end_page = $pager->current_page + 10;
$end_page = $pager->last_page if $pager->last_page < $end_page;
</%init>

% # -------------------------------------------------------------------------- <%def .page_link> <%args> $page </%args> <% $request->link( table => $request->model_class->table, action => $request->action, additional => $args, label => $page, ) %> <%init> my $args = "?page=$page";

my %params = %{ $request->params };

delete $params{page};

%params = () if ( $request->action ne 'list' && $request->action ne 'do_search' );

my $uri = URI->new;

$uri->query_form( %params );

$args .= "&".$uri->equery if $uri->equery;
</%init>
</%def>