On Tue, Dec 23, 2008 at 06:34:06AM -0500, Jesse Sheidlower wrote: > > Some time ago, I developed or stole a TT pager that I now use > in all of my Cat apps. It looks like this, though occasionally > with minor CSS tweaks:
Well, FWIW, here's my old code. I probably should clean up before posting and provide some config instead of hard-coded values, but... [% # pager.tt # # Creates stash entries: (all localized) # page_nav.summary = "Viewing: 41 - 50 of 200" # page_nav.previous = "Previous" link if exists # page_nav.next = "Next" link if exists # page_nav.pages = list of pages as html RETURN UNLESS pager.last_page > 1; page_nav.summary = loc( [ '<em>Viewing Page:</em> [_1] of [_2]', pager.current_page, pager.last_page, ] ); # Create url object to modify USE u = URL(c.uri_path, c.req.parameters ); IF pager.current_page > 1; lnk = u( p = pager.current_page - 1); label = loc('Previous'); page_nav.previous = "<a href='$lnk'><em>$label</em></a>"; END; IF pager.current_page < pager.last_page; lnk = u( p = pager.current_page + 1); label = loc('Next'); page_nav.next = "<a href='$lnk'><em>$label</em></a>"; END; # Set start and end position of sliding window IF pager.current_page <= 6; page_start = 1; page_end = 10; ELSE; page_start = pager.current_page - 5; page_end = page_start + 9; END; SET page_end = pager.last_page IF page_end > pager.last_page; pg = []; # list of pages FOR num IN [ page_start .. page_end ]; IF num == pager.current_page; pg.push( '<em>' _ num _ '</em>' ); NEXT; END; lnk = u( p = num); pg.push( "<a href='$lnk'>$num</a>"); END; page_nav.pages = pg; %] [% BLOCK formatted_page_nav %] <div class="pager"> <p> [% page_nav.summary %] </p> <ol> [%- "<li>$page_nav.previous</li>" IF page_nav.previous %] [%- FOR p = page_nav.pages %] <li>[% p %]</li> [%- END %] [%- "<li>$page_nav.next</li>" IF page_nav.next %] </ol> </div> [% END %] -- Bill Moseley mose...@hank.org Sent from my iMutt _______________________________________________ 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/