laasti/pagination

A small pagination library that produces data objects instead of HTML.

v0.2.2 2016-01-15 22:08 UTC

This package is auto-updated.

Last update: 2024-04-20 22:16:17 UTC


README

A small library to generate pagination.

Installation

composer require laasti/pagination

Usage

$pagination = new Pagination($currentPage, $total, $perPage, $baseUrl, $neighbours);

echo '<a href="'.$pagination->first()->link().'">First</a>';
echo '<a href="'.$pagination->previous()->link().'">Previous</a>';
foreach ($pagination as $page) {
    if ($page->isActive()) {
        echo '<b>'.$page->number().'</b>';
    } else {
        echo '<a href="'.$page->link().'">'.$page->number().'</a>';
    }
}
echo '<a href="'.$pagination->next()->link().'">Next</a>';
echo '<a href="'.$pagination->last()->link().'">Last</a>';

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

See CHANGELOG.md for more information.

Credits

Author: Sonia Marquette (@nebulousGirl)

License

Released under the MIT License. See LICENSE.txt file.