diff options
author | ivan <ivan> | 2006-10-25 17:36:28 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-10-25 17:36:28 +0000 |
commit | 5eb3dab3ea20a9861074a41bef19c9ac4dcb2336 (patch) | |
tree | aa65377cb8b9f0f32f2d05b3a441b828ef2a3d7b /httemplate/elements/pager.html | |
parent | 3a060deb9ca28876b17b4f6781abee3d1e233ba0 (diff) |
pagination patch from UNTD - limit the number of page links displayed and have a drop-down option for selecting number of entries per page
Diffstat (limited to 'httemplate/elements/pager.html')
-rw-r--r-- | httemplate/elements/pager.html | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/httemplate/elements/pager.html b/httemplate/elements/pager.html index 2327594a8..a53300f53 100644 --- a/httemplate/elements/pager.html +++ b/httemplate/elements/pager.html @@ -1,43 +1,55 @@ +% my %opt = @_; +% my $pager = ''; % +% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { % -% my %opt = @_; -% -% my $pager = ''; -% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { -% unless ( $opt{'offset'} == 0 ) { -% $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); -% - +% unless ( $opt{'offset'} == 0 ) { +% $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Previous</FONT></B></A> + +% } % -% } -% my $page = 0; -% for ( my $poff = 0; $poff < $opt{'total'}; $poff += $opt{'maxrecords'} ) { -% $page++; -% if ( $opt{'offset'} == $poff ) { +% my $page = 0; +% my $prevpage = 0; +% my $over = 0; +% my $step = $opt{total} / 10; # 10 evenly spaced +% for ( my $poff = 0; $poff < $opt{total}; $poff += $opt{maxrecords} ) { +% $page++; +% +% next unless +% $page <= 4 #first four +% || $page >= ( $opt{total} / $opt{maxrecords} ) - 3 #last four +% || abs( ($opt{offset}-$poff) / $opt{maxrecords} ) <= 3 #w/i 3 of current +% || $poff > $over # evenly spaced +% ; % - +% $over += $step if $poff > $over; +% +% if ( $opt{'offset'} == $poff ) { <FONT SIZE="+2"><% $page %></FONT> -% -% } else { -% $cgi->param('offset', $poff); -% +% } else { +% $cgi->param('offset', $poff); +% +% if ( $page > $prevpage+1 ) { + ... +% } <A HREF="<% $cgi->self_url %>"><% $page %></A> + +% } % -% } -% } -% unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { -% $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); +% $prevpage = $page; % - +% } +% +% unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { +% $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Next</FONT></B></A> % -% } -% } +% } % - +% } |