It looks like you're offline.
Open Library logo
additional options menu

This doc was last edited by Anand Chitipothu June 19, 2009.

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
$def with (q, first_page, last_page, this_page, per_page)
$# for now this is only for fulltext search.  it's pasted from the advanced search template
$# and modified, so advanced_search.tmpl should be refactored to use this.
$ _ = i18n.get_namespace('/search')
$ bracket_radius = 3
$ start_bracket = max(first_page, min(this_page - bracket_radius, last_page - 2*bracket_radius))
$ end_bracket = min(last_page, max(this_page + bracket_radius, first_page + 2*bracket_radius))

<div class="Pages">
    <strong>$_.more_results:</strong>&nbsp;
    $if this_page > first_page: <a href="$changequery(q=q,offset=(this_page-first_page-1)*per_page)" class="ChoosePage">&lt;&nbsp;PREV</a>&nbsp;
    $if start_bracket > first_page: <a href="$changequery(offset=0)" class="ChoosePage">$first_page</a>
    $if start_bracket > first_page+1: ...
    $for i in range(start_bracket, end_bracket+1):
	$if i == this_page: <b class="YouAreHere">$i</b>&nbsp;
	$else: <a href="$changequery(offset=(i-1)*per_page)" class="ChoosePage">$i</a>&nbsp;
    $if end_bracket < last_page - 1: ...
    $if end_bracket < last_page:
       <a href="$changequery(offset=(last_page-1)*per_page)" class="ChoosePage">$last_page</a>
    $if this_page < last_page: <a href="$changequery(offset=(this_page-first_page+1)*per_page)" class="ChoosePage">NEXT&nbsp;&gt;</a>
</div>