]> git.decadent.org.uk Git - maypole.git/blob - templates/factory/pager
6aed9c21c9cf024d31b0d37bdb1bc678069f6d14
[maypole.git] / templates / factory / pager
1 [%#
2
3 =head1 pager
4
5 This controls the pager display at the bottom (by default) of the list
6 and search views. It expects a C<pager> template argument which responds
7 to the L<Data::Page> interface.
8
9 #%]
10 [%
11 IF pager AND pager.first_page != pager.last_page;
12 %]
13 <p class="pager">Pages: 
14 [%
15     SET begin_page = pager.current_page - 10;
16     IF begin_page < 1;
17         SET begin_page = pager.first_page;
18     END;
19     SET end_page = pager.current_page + 10;
20     IF pager.last_page < end_page;
21         SET end_page = pager.last_page;
22     END;
23      FOREACH num = [begin_page .. end_page];
24           IF num == pager.current_page;
25             "<span class='current-page'>"; num; "</span>";
26           ELSE;
27             SET label = num;
28             SET args = "?page=" _ num;
29             SET args = args _ "&order=" _ request.params.order
30               IF request.params.order;
31             SET args = args _ "&amp;o2=desc"
32               IF request.params.o2 == "desc";
33             SET action = "list";
34             FOR col = classmetadata.columns.list;
35               IF request.params.$col;
36                 SET args = args _ "&" _ col _ "=" _ request.params.$col;
37                 SET action = "search";
38               END;
39             END;
40             link(classmetadata.table, action, args, label);
41           END;
42      END;
43 %]
44 </p>
45 [% END %]