pollen-solutions/pagination

Pollen Solutions - Pagination Component - Layer and utilities to paginate items in web applications

v1.0.1 2021-08-11 00:00 UTC

This package is auto-updated.

Last update: 2024-12-12 13:57:02 UTC


README

Latest Stable Version MIT Licensed PHP Supported Versions

Pollen Solutions Pagination Component provides layer and utilities to paginate items in web applications. It provides an adapter for Wordpress application.

Installation

composer require pollen-solutions/pagination

Basic Usage

use Pollen\Pagination\PaginationManager;
use Pollen\Pagination\Paginator;

$pagination = new PaginationManager();
$paginator = new Paginator(
    [
        'per_page' => 20,
        'total'    => 60,
    ]
);

var_dump($paginator->toArray());

$pagination->setPaginator($paginator);

echo $pagination;

Wordpress Usage

In this example, we consider that the current HTTP request corresponds to a search results page. ex. https://example.com/?s=a

use Pollen\Pagination\PaginationManager;

add_action('wp', function () {
    echo new PaginationManager();
    exit;
});

Through a controller