From c441332aeea4f0dbd9b0223b2ecceb532b7a71a3 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 10 Mar 2004 12:45:44 +0000 Subject: [PATCH] Paging support for searches too. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@82 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole/Model/CDBI.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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. -- 2.39.5