Short version: Using [% c.req.uri_with({ page => pager.next_page }) %] is fine for a simple single-field search (where the form uses GET instead of POST)... but how do we PAGE through (and/or cache) a multi-field form search that uses POST?
Long version: This is probably already a posted recipe somewhere, but I haven't had much luck finding answers via googling combinations of 'perl catalyst post cache pager' ... so pointers are welcome: # Form has lots of fields, we'll just nab a sample handful from the POST: my @terms = map{s/\s+//; $_} split /,/, $form->field('keywords'); # I know, but it's just an example, this isn't a robust search-field parser :) my %search = ( asof => { # date field "asof" must be within date range '>=' => $form->field('start_date'), '<=' => $form->field('end_date'), }, terms => [ # field "terms" can contain any of the keywords map { +{ -like => '%' . $_ . '%' } } @terms ], ); my $page = $c->req->param('page'); $page = 1 if ! defined( $page ) || ! $page || $page =~ /\D/; my $result = $c->model('Package')->search( \%search, {page=>$page} ); $c->stash->{results} = $result; $c->stash->{pager} = $result->pager; Then, in the template: <a href="[% c.req.uri_with({page => pager.prev_page}) %]">Prev</a> <a href="[% c.req.uri_with({page => pager.next_page}) %]">Next</a> That works well for simple GET forms where the ?field=val syntax is used in the URI. What's the approach for paging the (cached?) query results from a complex-field POSTed search form? I'm imagining a two-table DB solution where we cache the found row-id's in table `cached_search_row` and link that to `cached_search`, then have the cached_search.id mentioned in the URI. I'm hoping there's a better way someone has already conjured up that doesn't have all the drawbacks of this approach that we haven't even thought of... Thanks in advance! -- will trillich "It's only by saying 'no' that you can concentrate on the things that are really important." -- Steve Jobs -- will trillich "It's only by saying 'no' that you can concentrate on the things that are really important." -- Steve Jobs
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/