Posted by: moryadesigns on: September 5, 2009
Basically there are two types of pagination, Jumping and Sliding. In the jumping type the current page jumps from the starting position in a frame till the end and goes till the get before moving on to the next frame. Whereas, in the sliding type the current page remains in the center of the frame (of course except the current page is not in the starting or ennding half of the pageset), here is an illustration of the jumping and sliding pagination types which will help you understand the logic better.
Jumping
[1] 2 3 4 5 => # first frame: [1-5] <= 1 [2] 3 4 5 => <= 1 2 [3] 4 5 => <= 1 2 3 [4] 5 => <= 1 2 3 4 [5] => # current page jumps to the next frame <= [6] 7 8 9 10 => # second frame: [6-10] <= 6 [7] 8 9 10 => <= 6 7 [8] 9 10 =>
Sliding
[1] 2 3 4 5 => <= 1 [2] 3 4 5 => <= 1 2 [3] 4 5 => # from here onwards current page remaing in the center <= 2 3 [4] 5 6 => # current page <= 3 4 [5] 6 7 => # and it stays there... <= 4 5 [6] 7 8 => <= 5 6 [7] 8 9 => <= 6 7 [8] 9 10 =>
The Code
## the default is Jumping use Data::Pageset; my $total_entries = 500; my $entries_per_page = 10; my $current_page = 30; my $pages_per_set = 11; my $paging_jump = Data::Pageset->new({ 'total_entries' => $total_entries, 'entries_per_page' => $entries_per_page, # Optional, will use defaults otherwise. 'current_page' => $current_page, 'pages_per_set' => $pages_per_set }); my $paging_slide = Data::Pageset->new({ 'total_entries' => $total_entries, 'entries_per_page' => $entries_per_page, # Optional, will use defaults otherwise. 'current_page' => $current_page, 'pages_per_set' => $pages_per_set, 'mode' => 'slide' }); # Print the page numbers of the current set : Jumping foreach my $page (@{$paging->pages_in_set()}) { if($page == $paging_jump->current_page()) { print "[$page] "; } else { print "$page "; } } print "\n\n"; # Print the page numbers of the current set : Jumping foreach my $page (@{$paging_slide->pages_in_set()}) { if($page == $paging->current_page()) { print "[$page] "; } else { print "$page "; } }
September 18, 2009 at 9:51 am
Hi,
thanks for the great quality of your website, every time i come here, i’m amazed.
I would like to suggest you to come and try the true black hattitude.
you’ll find a lot of stuff dealing with the black hattitude,
You can buy some black hattitude, rent black hattitude, steal black hattitude, or find
the ultimate black hattitude on our site ofblack hattitude.
have a nice day,
Mike Litoris
black hattitude
you’ll find here also some good black hattitude
September 19, 2009 at 4:37 am
Thanks dear