From: Simon Cozens Date: Wed, 10 Mar 2004 12:45:44 +0000 (+0000) Subject: Paging support for searches too. X-Git-Tag: 2.10~280 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=c441332aeea4f0dbd9b0223b2ecceb532b7a71a3;p=maypole.git Paging support for searches too. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@82 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 0be76f9..bb72f59 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -82,18 +82,23 @@ sub search :Exported { my %values = map { $_ => {$oper, $params{$_} } } grep { $params{$_} and $fields{$_} } keys %params; + $self = $self->do_pager($r); $r->objects([ %values ? $self->search_where(%values) : $self->retrieve_all ]); $r->template("list"); $r->{template_args}{search} = 1; } +sub do_pager { + my ($self, $r) = @_; + if ( my $rows = $r->config->{rows_per_page}) { + return $r->{template_args}{pager} = $self->pager($rows, $r->query->{page}); + } else { return $self } +} + sub list :Exported { my ($self, $r) = @_; my %ok_columns = map {$_ => 1} $self->columns; - if ( my $rows = $r->config->{rows_per_page}) { - $self = $self->pager($rows, $r->query->{page}); - $r->{template_args}{pager} = $self; - } + $self = $self->do_pager($r); my $order; if ($order = $r->query->{order} and $ok_columns{$order}) { $r->objects([ $self->retrieve_all_sorted_by( $order.