Data::Page::Nav - Module for pages navigation
my $page = Data::Page::Nav->new; $page->total_entries(110); $page->entries_per_page(10); $page->current_page(4); $page->number_of_pages(5); # join all pages print join '-', $page->pages_nav; # 2-3-4-5-6 # first navigation page print $page->first_nav_page; # 2 # last navigation page print $page->last_nav_page; # 6
Or
my $total_entries = 110; my $entries_per_page = 10; my $current_page = 4; my $number_of_pages = 5; my $page = Data::Page::Nav->new( $total_entries, $entries_per_page, $current_page, $number_of_pages ); # join all pages print join '-', $page->pages_nav; # 2-3-4-5-6 # first navigation page print $page->first_nav_page; # 2 # last navigation page print $page->last_nav_page; # 6
This module simply provides methods for you to create navigation of pages, using as a base the module Data::Page.
This method returns the numbers in an array or arrayref depending on the context, too it can set the number of pages, but is optional:
# if the current page is 7 print join '-', $page->pages_nav; # 3-4-5-6-7-8-9-10-11-12 print join '-', $page->pages_nav(3); # 6-7-8 print join '-', $page->pages_nav(7); # 4-5-6-7-8-9-10
This method returns the first value in the list returned by pages_nav, too it can set the number of pages, but is optional:
# if the current page is 7 print $page->first_nav_page; # 3 print $page->first_nav_page(3); # 6 print $page->first_nav_page(7); # 4
This method returns the last value in the list returned by pages_nav, too it can set the number of pages, but is optional:
# if the current page is 7 print $page->last_nav_page; # 12 print $page->last_nav_page(3); # 8 print $page->last_nav_page(7); # 10
The other methods are the same as the Data::Page, and you can see them in Data::Page#METHODS
Data::Page.
Lucas Tiago de Moraes lucastiagodemoraes@gmail.com
lucastiagodemoraes@gmail.com
This software is copyright (c) 2022 by Lucas Tiago de Moraes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Page::Nav, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Page::Nav
CPAN shell
perl -MCPAN -e shell install Data::Page::Nav
For more information on module installation, please visit the detailed CPAN module installation guide.