|
1 <%def name="paginate(url, count, page_cur, page_max, _more=None, _last=False, **args)"> |
|
2 <%doc> |
|
3 Pagination works using page numbers, with a specific number of maximum pages displayed. If _more is True, |
|
4 then instead of a "Next" button, we have a "More" button, which goes to the max+1'th page, unless _last is |
|
5 True, whereupon it's not displayed |
|
6 </%doc> |
|
7 <div class="paginate"> |
|
8 <ul> |
|
9 <li> |
|
10 % if page_cur > 1 : |
|
11 <a href="${h.build_url(url, count=count, page=page_cur-1, max=max, **args)}">« Prev</a> |
|
12 % else : |
|
13 <span>« Prev</span> |
|
14 %endif |
|
15 </li> |
|
16 % for page in xrange(1, page_max + 1) : |
|
17 <li> |
|
18 % if page == page_cur : |
|
19 <strong>${page}</strong> |
|
20 % else : |
|
21 <a href="${h.build_url(url, count=count, page=page, max=page_max, **args)}">${page}</a> |
|
22 % endif |
|
23 </li> |
|
24 % endfor |
|
25 <li> |
|
26 % if _more and _last : |
|
27 <span>More »</span> |
|
28 % elif _more : |
|
29 <a href="${h.build_url(url, count=count, page=page_max+1, **args)}">More »</a> |
|
30 % elif page_cur == page_max : ## last page |
|
31 <span>Next »</span> |
|
32 % else : |
|
33 <a href="${h.build_url(url, count=count, page=page_cur+1, **args)}">Next »</a> |
|
34 % endif |
|
35 </li> |
|
36 </ul> |
|
37 </div> |
|
38 </%def> |
|
39 |