[Catalyst] Re: OT: Better TT pager?
kakimoto at tpg.com.au
kakimoto at tpg.com.au
Sun Jun 21 04:37:18 GMT 2009
Hi, there, Oliver and everyone:)
Thanks for your posting:)
Referring to
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg05232.html, I
adopted the code given into my template and it looks really good but the
hyperlink doesn't have any value. I suppose it's because [%
c.req.uri_with(...) %] is not defined.
1)why is the Catalyst request variable being used instead of the
Catalyst object?
2)how can we get the Catalyst request working properly (ie to be defined)?
thank you :)
K . akimoto
---------------------
Oliver Charles
Thu, 22 Jan 2009 07:50:17 -0800
I might as well join in with this :) Here's what we use at work:
[% IF pager %]
<ul class="paginator">
<li class="counter">Page [% pager.current_page %] of [%
pager.last_page %]</li>
<li><a href="[% c.req.uri_with( page => pager.first_page )
%]">«</a></li>
[% IF pager.previous_page %]
<li><a href="[% c.req.uri_with( page =>
pager.previous_page ) %]"><</a></li>
[% END %]
[% start = (pager.current_page - 3) > 0 ? (pager.current_page -
3) : 1;
FOREACH page IN [ start .. pager.last_page ] %]
[% LAST IF loop.count > 6 %]
<li[% IF pager.current_page == page; ' class="current"'; END %]>
<a href="[% c.req.uri_with( page => page ) %]">[% page
%]</a>
</li>
[% END %]
[% IF pager.next_page %]
<li><a href="[% c.req.uri_with( page => pager.next_page )
%]">></a></li>
[% END %]
<li><a href="[% c.req.uri_with( page => pager.last_page )
%]">»</a></li>
</ul>
[% END %]
Though my colleague rightly suggested we subclass Data::Page and
perform the sliding window in there. This shows first page, previous
page, the current page surrounded by near-by pages. Seems to do the
job so far!
More information about the Catalyst
mailing list