X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=ex%2Ffancy_example%2Ftemplates%2Ffactory%2Fpager;fp=ex%2Ffancy_example%2Ftemplates%2Ffactory%2Fpager;h=78c89fd6aa93da92fef0f4d59738b37f52588db5;hb=7bb021648c28d2f70ec2853f0d01dd49c6437460;hp=0000000000000000000000000000000000000000;hpb=c3973978e1373a262d13da63c9e9ecfde4b72cc7;p=maypole.git diff --git a/ex/fancy_example/templates/factory/pager b/ex/fancy_example/templates/factory/pager new file mode 100644 index 0000000..78c89fd --- /dev/null +++ b/ex/fancy_example/templates/factory/pager @@ -0,0 +1,48 @@ +[%# + +=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: +[% + UNLESS pager_action; + SET pager_action = request.action; + END; + + 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; ""; + ELSE; + SET label = num; + SET args = "?page=" _ num; + SET args = args _ "&order=" _ request.params.order + IF request.params.order; + SET args = args _ "&o2=desc" + IF request.params.o2 == "desc"; + FOR col = classmetadata.columns.list; + IF request.params.$col; + SET args = args _ "&" _ col _ "=" _ request.params.$col; + SET action = "search"; + END; + END; + link(classmetadata.table, pager_action, args, label); + END; + END; +%] +

+[% END %]