Download the PHP package voodoophp/paginator without Composer
On this page you can find all versions of the php package voodoophp/paginator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voodoophp/paginator
More information about voodoophp/paginator
Files in voodoophp/paginator
Package paginator
Short Description Paginator is a simple class that allows you to create pagination. It doesn't require any database connection. It is compatible with Twitter's Bootstrap Framework, by using the CSS class pagination that is also attached.
License MIT
Homepage https://github.com/mardix/Paginator
Informations about the package paginator
Paginator 2.x.x
A paginator that makes it easy and simple
Name: Paginator
License: MIT
Author: Mardix
Version : 2.x.x
Requirements: PHP >= 5.4
About Paginator
Paginator is a simple class that allows you to create pagination for your application. It doesn't require any database connection. It only requires the total of items found and from there it will create a pagination that can be export to HTML or Array. It is also compatible with Twitter's Bootstrap Framework.
Install Paginator
You can just download Paginator as is, or with Composer.
To install with composer, add the following in the require key in your composer.json file
"voodoophp/paginator": "2.*"
composer.json
{
"name": "voodoophp/myapp",
"description": "My awesome Voodoo App",
"require": {
"voodoophp/paginator": "2.*"
}
}
Create a Pagination
Paginator makes it easy to create pagination. It only requires the URL that contains the page number pattern, the total items, and the total of items per page.
http://site.com/search?q=flower&page=15
or
http://site.com/genres/pop/page/15
Paginator will automatically match the page number with the url above, and create pagination for the rest of the pages based on the total items and items per page provided.
Catching the page number
Paginator requires the keyword (:num) in the page number pattern to match the page number in the URL.
Page number pattern are set in the following format
For friendly URL, it will capture http://site.com/page/25
/page/(:num)
For normal URL, it will capture http://site.com/?page=25
page=(:num)
Page number pattern is set in
Voodoo\Paginator::setUrl($url, $pagePattern);
On both examples it will catch the page number [25] and create from there the start and the end of the pagination.
Any variation of the page number pattern is OK, as long as it includes (:num)
A Simple Example
<html>
<head>
<link rel="stylesheet" href="./assets/paginator.css">
<title>Paginator Example</title>
</head>
<body>
<?= $paginator; ?>
</body>
</html>
Will render something like this:
[First] [<< Prev] [1] [2] [3] [4] [5] [6] [Next >>] [Last]
With links that look like:
<a href='http://mysite.com/hip-hop/page/6'>6</a>
Methods
Voodoo\Paginator::__construct()
<li class='<?= ($page["is_current"]) ? "active" : ""; ?>'>
<a href='<?= $page["url"]; ?>'><?= $page["label"]; ?></a>
</li>
</ul>
String Voodoo\Paginator::toHtml()
Will return a formatted HTML, compatible with Bootstrap framework
<html>
<head>
<link rel="stylesheet" href="./assets/paginator.css">
<title>Paginator SQL Example</title>
</head>
<body>
<?= $paginator; ?>
</body>
</html>
Please refer to the example directory for examples
(c) This Year Mardix :)