Peter Sørensen wrote:
> Hi,
>
> I'm using Catalyst and TT and generates a big array which I would like
> to split into pages when outputting.
>
> Googling around I found references to use TT's table plugin, Perl's
> Data::Page
> object ...
>
> I would like to aks this list, what would be the best way to deal with this?
> I would prefer to keep this as close to the VIEW as possible.
>
>
> Regards and thanks
>
>
> Peter Sørensen/University of Southern Denmark/mail: [EMAIL PROTECTED]
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
>
I use in my template on top of the page this:
Page [% pager.current_page %]
[% IF pager.current_page != pager.first_page %]
<a href="[% c.request.uri_with( page => pager.first_page ) %]"
title="First Page">
<img src="[% site.url.pics %]/first.png" border="0"
style="vertical-align: text-bottom;">
</a>
[% END %]
[% IF pager.previous_page %]
<a href="[% c.request.uri_with( page => pager.previous_page ) %]"
title="Previous Page">
<img src="[% site.url.pics %]/previous.png" border="0"
style="vertical-align: text-bottom;">
</a>
[% END %]
[% IF pager.next_page %]
<a href="[% c.request.uri_with( page => pager.next_page ) %]"
title="Next Page">
<img src="[% site.url.pics %]/next.png" border="0"
style="vertical-align: text-bottom;">
</a>
[% END %]
[% IF pager.current_page != pager.last_page %]
<a href="[% c.request.uri_with( page => pager.last_page ) %]"
title="Last Page">
<img src="[% site.url.pics %]/last.png" border="0"
style="vertical-align: text-bottom;">
</a>
[% END %]
.... then in my controller:
sub view : Local {
my ( $self, $c ) = @_;
my $page = $c->req->param('page') || 1;
my $rs = $c->model('AppModelDB::Clients')->search(undef,
{
page => $page,
rows => 20,
});
$c->stash->{rs} = $rs;
$c->stash->{pager} = $rs->pager;
$c->stash->{template} = 'clients/view.tt2';
}
you need Data::Page to do that.
Angel.
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates