NAME
DBIx::MoCo::Pageset - A flexible pager utility for DBIx::MoCo using Data::Pageset
VERSION
Version 0.01
SYNOPSIS
## DBIx::MoCo class.
package Blog::User;
use base qw 'Blog::MoCo';
use DBIx::MoCo::Pageset;
__PACKAGE__->table('user');
## your client code.
## you can easily use pager util.
use Blog::User;
my $pager = Blog::User->pager( {
entries_per_page => 20,
current_page => 1,
pages_per_set => 10,
} );
my @users = $pager->retrieve_all;
DESCRIPTION
DBIx::MoCo::Pageset
is pager class for DBIx::MoCo
using <Data::Pageset>. This module referred to <Class::DBI::Pageset> and made it.
EXAMPLE
client code
## your client code.
## you can easily use pager util.
use CGI;
use Template;
use Blog::User;
my $q = CGI->new;
my $pager = Blog::User->pager( {
entries_per_page => 20,
current_page => $q->param('p') || 1,
pages_per_set => 10,
} );
my $entries = $pager->retrieve_all;
my $template = Template->new;
$template->process($input, {
pager => $pager,
entries => $entries,
});
template (TT)
[% IF pager.total_entries %][% pager.entries_per_page * ( pager.current_page - 1 ) + 1 %][% ELSE %]0[% END # END IF %]
-
[% pager.entries_per_page * ( pager.current_page - 1 ) + pager.entries_on_this_page %] entries
( [% pager.total_entries %] total entries )
[% IF pager.previous_page %]
<a href="/path/?p=[% pager.previous_page %]">prev</a>
[% ELSE %]
prev
[% END # END IF %]
[% FOREACH num IN pager.pages_in_set %]
[% IF num == pager.current_page %]<strong>[% num %]</strong>
[% ELSE %]<a href=/path/?p=[% num %]">[% num %]</a>
[% END # END IF %]
[% END # END FOREACH %]
[% IF pager.next_page %]
<a href="/path/?p=[% pager.next_page %]">prev</a>
[% ELSE %]
next
[% END # END IF %]
[% FOREACH e IN entries %]
[% e.title | html %]
[% END # END %]
SEE ALSO
DBIx::MoCo
, Data::Pageset
When I use other O/R Mapper, please use Class::DBI::Pageset
, DBIx::Class::ResultSet::Data::Pageset
BUGS
Please report any bugs or suggestions at http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-MoCo-Pageset
AUTHOR
syushi matsumoto, <matsumoto at alink.co.jp>
COPYRIGHT AND LICENSE
Copyright (C) 2009 Alink INC. all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.