1 ## special overrides... |
|
2 <%def name="paginate_left()"> |
|
3 |
|
4 </%def> |
|
5 |
|
6 <%def name="paginate(url, count, page_cur, page_max, _more=None, _last=False, **args)"> |
|
7 <%doc> |
|
8 Pagination works using page numbers, with a specific number of maximum pages displayed. If _more is True, |
|
9 then instead of a "Next" button, we have a "More" button, which goes to the max+1'th page, unless _last is |
|
10 True, whereupon it's not displayed. |
|
11 |
|
12 Can be called using <%call>, whereupon caller.left/caller.right can define additional data to display at the |
|
13 left/right of the pagination ul. |
|
14 </%doc> |
|
15 <div class="paginate"> |
|
16 <ul> |
|
17 % if caller and caller.right : |
|
18 <li class="paginate-right"> |
|
19 ${caller.right()} |
|
20 </li> |
|
21 % endif |
|
22 % if caller and caller.left : |
|
23 <li class="paginate-left"> |
|
24 ${caller.left()} |
|
25 </li> |
|
26 % endif |
|
27 <li> |
|
28 % if page_cur > 1 : |
|
29 <a href="${h.build_url(url, count=count, page=page_cur-1, max=max, **args)}">« Prev</a> |
|
30 % else : |
|
31 <span>« Prev</span> |
|
32 %endif |
|
33 </li> |
|
34 % for page in xrange(1, page_max + 1) : |
|
35 <li> |
|
36 % if page == page_cur : |
|
37 <strong>${page}</strong> |
|
38 % else : |
|
39 <a href="${h.build_url(url, count=count, page=page, max=page_max, **args)}">${page}</a> |
|
40 % endif |
|
41 </li> |
|
42 % endfor |
|
43 % if _more and not _last : |
|
44 <li>…</li> |
|
45 % endif |
|
46 <li> |
|
47 % if _more and _last : |
|
48 <span>More »</span> |
|
49 % elif _more : |
|
50 <a href="${h.build_url(url, count=count, page=page_max+1, **args)}">More »</a> |
|
51 % elif page_cur == page_max : ## last page |
|
52 <span>Next »</span> |
|
53 % else : |
|
54 <a href="${h.build_url(url, count=count, page=page_cur+1, **args)}">Next »</a> |
|
55 % endif |
|
56 </li> |
|
57 </ul> |
|
58 </div> |
|
59 </%def> |
|
60 |
|