Scroll to navigation

Catmandu::Paged(3pm) User Contributed Perl Documentation Catmandu::Paged(3pm)

NAME

Catmandu::Paged - Base class for packages that need paging result sets

SYNOPSIS

    # Create a package that needs page calculation
    package MyPackage;
    use Moo;
    with 'Catmandu::Paged';
    sub start {
        12; # Starting result
    }
    sub limit  {
        10; # Number of results per page
    }
    sub total {
        131237128371; # Total number of results;
    }
    package main;
    my $x = MyPackage->new;
    printf "Start page: %s\n" , $x->first_page;
    printf "Last page: %s\n" , $x->last_page;
    printf "Current page: %s\n" , $x->page;
    printf "Next page: %s\n" , $x->next_page;

DESCRIPTION

Packages that use Catmandu::Paged as base class and implement the methods "start", "limit" and "total" get for free methods that can be used to do page calculation.

OVERWRITE METHODS

Returns the index of the first item in a result page.
Returns the number of results in a page.
Returns the total number of search results.

INSTANCE METHODS

Returns the index the first page in a search result containing 0 or more pages.
Returns the index of the last page in a search result containing 0 or more pages.
Returns the number items on the current page.
Returns the current page index.
Returns the previous page index.
Returns the next page index.
Returns the result index of the first result on the page.
Returns the previous pages and next pages, depending on the current position in the result set.

SEE ALSO

Catmandu::Hits

2024-07-02 perl v5.38.2