[Catalyst] Help with paging

Octavian Rasnita orasnita at gmail.com
Wed Jul 16 13:36:03 BST 2008


----- Original Message ----- 

> 2008/7/16 Octavian Rasnita <orasnita at gmail.com>:
>> From: "Dermot" <paikkos at googlemail.com>
>>> # Arg where is pager?
>>
>> Try using:
>>
>> sub list : Local {
>> my ($self, $c) = @_;
>>
>> my $items = $c->model('MyDB::Items')->search({},{
>> page => $page,
>> rows => 20,
>> });
> 
> Where does $page come from? Should I pick that up from @_?
> 

Well, my code was wrong because I have forgotten to define $page.

You can get it using

$c->req->param('page');

as you did, or you can also use something like:

package MyApp::Controller::Clients;

sub list : Local {
my ($self, $c, $page) = @_;
$page ||= 1;

And you will be able to display the page 3, accessing:

http://localhost:3000/clients/list/3

Octavian




More information about the Catalyst mailing list