X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=templates%2Ffactory%2Fpager;h=bb78138691e6377de22150bc01273e2f31ce19b3;hb=d7675a8712c9197e462c1a260138cae497092356;hp=9defa40e0417d6efd028e0ed31579da4a3ffe487;hpb=7232f39368bec26e484089f9f81ab6b6dc94e9eb;p=maypole.git diff --git a/templates/factory/pager b/templates/factory/pager index 9defa40..bb78138 100644 --- a/templates/factory/pager +++ b/templates/factory/pager @@ -1,18 +1,45 @@ +[%# + +=head1 pager + +This controls the pager display at the bottom (by default) of the list +and search views. It expects a C template argument which responds +to the L interface. + +#%] [% IF pager AND pager.first_page != pager.last_page; %] - -

Pages: +

Pages: [% - FOREACH num = [pager.first_page .. pager.last_page]; + SET begin_page = pager.current_page - 10; + IF begin_page < 1; + SET begin_page = pager.first_page; + END; + SET end_page = pager.current_page + 10; + IF pager.last_page < end_page; + SET end_page = pager.last_page; + END; + FOREACH num = [begin_page .. end_page]; IF num == pager.current_page; - "["; num; "] "; + ""; num; ""; ELSE; - ''; - "["; num; "]"; - ' '; + SET label = num; + SET args = "?page=" _ num; + SET args = args _ "&order=" _ request.query.order + IF request.query.order; + SET args = args _ "&o2=desc" + IF request.query.o2 == "desc"; + SET action = "list"; + FOR col = classmetadata.columns.list; + IF request.query.$col; + SET args = args _ "&" _ col _ "=" _ request.query.$col; + SET action = "search"; + END; + END; + link(classmetadata.table, action, args, label); END; END; %] -

+

[% END %]