|
Data::Pagination - Paginal navigation on some data |
Data::Pagination - Paginal navigation on some data
use Data::Pagination;
# previously needs to check total number of entries. it can be # count of SQL records or length of array or something other. # # example: SELECT count(*) ... # # note: if no records exists, then no needs to continue processing. # enough to tell the user about that.
my $pg = Data::Pagination->new(
$total_entries, # - total number of entries (>= 1)
#
$entries_per_page, # - how much records (>= 1) maximum you want
# to see on one page.
#
$pages_per_set, # - how much pages you want to see in pages
# set. if you don't want to use this
# feature, then don't use, but some number
# (>= 1) must be presented here.
#
$current_page # - user specified number of page from
# request. must contain some integer
# number (don't forget to check this).
);
# now, for getting slice of data, use properties from
# "slice params" group.
#
# example: SELECT ...
# LIMIT $pg->{start_of_slice}, $pg->{length_of_slice}
# all properties from "statistics" group are copied from arguments,
# and with some properties from other groups can be used for
# shown some statistic information to user.
#
# example:
#
# $pg->{total_pages}
# / $pg->{total_entries}
# Total pages: 20 /
# Total records: 200
# Shown from 61 to 70 records
# \ \
# \ $pg->{start_of_slice} + 1
# $pg->{end_of_slice} + 1
#
# properties from "pages control" and "pages set control" intended
# for construction paginal navigation panel.
#
# example (simple):
#
# <-- previous page | next page -->
# / \
# $pg->{prev_page} $pg->{next_page}
#
# example (advanced):
#
# $pg->{current_page}
# |
# $pg->{prev_page} | $pg->{next_page}
# \ | /
# << < 6 [7] 8 9 10 > >>
# / / \ \
# $pg->{page_of_prev_set} / \ $pg->{page_of_next_set}
# / \
# $pg->{start_of_set} $pg->{end_of_set}
#
#
This class intended for organization of paginal navigation on some data. Basically intended for construction of paginal navigation panels on web sites.
Arguments:
Note: all arguments are required and must contains only integer numbers.
Slice params:
Statistics:
Pages control:
Pages set control:
Data::Page Data::Paginate Data::Paginated HTML::Paginator Data::SimplePaginator
Andrian Zubko <ondr@cpan.org>
|
Data::Pagination - Paginal navigation on some data |