adding a pagination bar
This commit is contained in:
parent
5d3d4523f4
commit
71894b6830
2 changed files with 31 additions and 44 deletions
|
@ -445,7 +445,8 @@ for (my $i=0;$i<=@servers;$i++) {
|
|||
my $server = $servers[$i];
|
||||
if ($server =~/biblioserver/) { # this is the local bibliographic server
|
||||
$hits = $results_hashref->{$server}->{"hits"};
|
||||
my @newresults = searchResults( $search_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}});
|
||||
my $page = $cgi->param('page') || 0;
|
||||
my @newresults = searchResults( $search_desc,$hits,$results_per_page,$page,@{$results_hashref->{$server}->{"RECORDS"}});
|
||||
$total = $total + $results_hashref->{$server}->{"hits"};
|
||||
if ($hits) {
|
||||
$template->param(total => $hits);
|
||||
|
@ -453,24 +454,31 @@ for (my $i=0;$i<=@servers;$i++) {
|
|||
$template->param(results_per_page => $results_per_page);
|
||||
$template->param(SEARCH_RESULTS => \@newresults);
|
||||
|
||||
my @page_numbers;
|
||||
my $pages = ceil($hits / $results_per_page);
|
||||
my $current_page_number = 1;
|
||||
$current_page_number = ($offset / $results_per_page + 1) if $offset;
|
||||
my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
|
||||
my $next_page_offset = $offset + $results_per_page;
|
||||
for (my $j=1; $j<=$pages;$j++) {
|
||||
my $this_offset = (($j*$results_per_page)-$results_per_page);
|
||||
my $this_page_number = $j;
|
||||
my $highlight = 1 if ($this_page_number == $current_page_number);
|
||||
if ($this_page_number <= $pages) {
|
||||
push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by };
|
||||
}
|
||||
}
|
||||
$template->param(PAGE_NUMBERS => \@page_numbers,
|
||||
previous_page_offset => $previous_page_offset,
|
||||
next_page_offset => $next_page_offset) unless $pages < 2;
|
||||
}
|
||||
# my @page_numbers;
|
||||
# my $pages = ceil($hits / $results_per_page);
|
||||
# my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
|
||||
# my $next_page_offset = $offset + $results_per_page;
|
||||
# for (my $j=1; $j<=$pages;$j++) {
|
||||
# my $this_offset = (($j*$results_per_page)-$results_per_page);
|
||||
# my $this_page_number = $j;
|
||||
# my $highlight = 1 if ($this_page_number == $current_page_number);
|
||||
# if ($this_page_number <= $pages) {
|
||||
# push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by };
|
||||
# }
|
||||
# }
|
||||
# $template->param(PAGE_NUMBERS => \@page_numbers,
|
||||
# previous_page_offset => $previous_page_offset,
|
||||
# next_page_offset => $next_page_offset) unless $pages < 2;
|
||||
|
||||
$template->param(
|
||||
pagination_bar => pagination_bar(
|
||||
"/cgi-bin/koha/catalogue/search.pl?q=$search_desc&",
|
||||
getnbpages($hits, $results_per_page),
|
||||
$page,
|
||||
'page'
|
||||
),
|
||||
);
|
||||
}
|
||||
} # end of the if local
|
||||
else {
|
||||
# check if it's a z3950 or opensearch source
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
<form action="/cgi-bin/koha/catalogue/search.pl" method="get">
|
||||
<table>
|
||||
|
@ -189,6 +188,7 @@
|
|||
<!-- RESORT END -->
|
||||
</form>
|
||||
<!-- TABLE RESULTS START -->
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
|
@ -294,30 +294,9 @@
|
|||
</div>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF NAME="PAGE_NUMBERS" -->
|
||||
<div class="pages">
|
||||
<!-- Row of numbers corresponding to search result pages -->
|
||||
<!-- TMPL_IF NAME="previous_page_offset" -->
|
||||
<a class="nav" href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_VAR NAME="searchdesc" -->&offset=<!-- TMPL_VAR NAME="previous_page_offset" -->">
|
||||
<< Previous
|
||||
</a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_LOOP NAME="PAGE_NUMBERS" -->
|
||||
<!-- TMPL_IF NAME="highlight" -->
|
||||
<span class="current"><!-- TMPL_VAR NAME="pg" --></span>
|
||||
<!-- TMPL_ELSE -->
|
||||
<a class="nav" href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_VAR NAME="searchdesc" -->&offset=<!-- TMPL_VAR NAME="offset" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->">
|
||||
<!-- TMPL_VAR NAME="pg" -->
|
||||
</a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- TMPL_IF NAME="next_page_offset" -->
|
||||
<a class="nav" href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_VAR NAME="searchdesc" -->&offset=<!-- TMPL_VAR NAME="next_page_offset" -->">
|
||||
Next >>
|
||||
</a>
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
<!-- /TMPL_IF -->
|
||||
<div class="pages">
|
||||
<!-- TMPL_VAR NAME='pagination_bar'-->
|
||||
</div>
|
||||
|
||||
<!-- TMPL_IF NAME="outer_sup_results_loop" -->
|
||||
<h3><!-- TMPL_LOOP NAME="outer_sup_results_loop" --></h3>
|
||||
|
|
Loading…
Reference in a new issue