This doc was last edited by Edward Betts July 12, 2010.
plugin
upstream
Templates in the website are disabled now. Editing them will not have any effect on the live website.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$def with (page, num_found, results_per_page)
$ pages = (num_found / results_per_page) + 1
$if pages != 1:
$ pages_in_set = 10
$ half = pages_in_set/2
$if pages < pages_in_set:
$ first_page_in_set = 1
$ last_page_in_set = pages
$elif page < half:
$ first_page_in_set = 1
$ last_page_in_set = min((pages_in_set, pages))
$elif page > (pages-half):
$ first_page_in_set = max((pages-pages_in_set, 1))
$ last_page_in_set = pages
$else:
$ first_page_in_set = max((page-half, 1))
$ last_page_in_set = page+half
<div class="clearfix"></div>
<div class="pagination collapse">
$if page != 1:
<a href="$changequery(page=None)" class="ChoosePage">« First</a>
<a href="$changequery(page=page-1)" class="ChoosePage">< Previous</a>
$for p in range(first_page_in_set, last_page_in_set+1):
$if p == page:
<span class="this">$p</span>
$else:
<a href="$changequery(page=p)" class="ChoosePage">$p</a>
$if page < pages:
<a href="$changequery(page=page+1)" class="ChoosePage">Next ></a>
<a href="$changequery(page=pages)" class="ChoosePage">Last »</a>
</div> |