Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neutron-pro/neutronstars-pagination
https://github.com/neutron-pro/neutronstars-pagination
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/neutron-pro/neutronstars-pagination
- Owner: Neutron-Pro
- License: apache-2.0
- Created: 2021-01-16T12:52:07.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-20T02:08:24.000Z (almost 4 years ago)
- Last Synced: 2024-12-07T01:35:22.889Z (about 1 month ago)
- Language: PHP
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# Pagination API for PHP
![Example Pagination 1](exemples/assets/img/pagination-1.jpg)
![Example Pagination 2](exemples/assets/img/pagination-2.jpg)#Installation
```
composer require neutronstars/pagination
```
```json
{
"require": {
"neutronstars/pagination": ">=1.1.*"
}
}
```If you want use the css style:
```html```
#Example
```php
3,
'key' => ':page',
'url' => '?page=:page',
'build-empty' => false,
'previous-next' => [
'active' => false,
'next-content' => 'Next',
'previous-content' => 'Previous',
'hidden' => true
],
'first-last' => [
'active' => false,
'first-content' => '«',
'last-content' => '»',
'hidden' => true
],
'css' => [
'parent-class' => 'pagination',
'child-class' => 'pagination-item',
'child-class-active' => 'pagination-item-active',
'separator-class' => 'pagination-separator',
'separator-content' => '...',
'previous-next-class' => 'pagination-pn-item',
'previous-next-class-active' => 'pagination-pn-item-active',
'first-last-class' => 'pagination-fl-item',
'first-last-class-active' => 'pagination-fl-item-active'
]
];$currentPage = 1;
$itemPerPage = 10;
$totalItem = 200;
echo new Pagination($currentPage, $itemPerPage, $totalItem, $options);
```#Callback
```php
[
'active' => true,
'hidden' => false
],
'previous-next' => [
'active' => true,
'hidden' => false
]
]);echo $pagination->toHTML(function ($type, $page) use ($pagination) {
switch ($type)
{
case PaginatorCallback::SEPARATOR_TYPE:
return '...';
case PaginatorCallback::FIRST_PAGE_TYPE:
return '↞';
case PaginatorCallback::PREVIOUS_PAGE_TYPE:
return 'Previous';
case PaginatorCallback::PAGE_TYPE:
return ''.$page.'';
case PaginatorCallback::CURRENT_PAGE_TYPE:
return ''.$page.'';
case PaginatorCallback::NEXT_PAGE_TYPE:
return 'Next';
case PaginatorCallback::LAST_PAGE_TYPE:
return '↠';
}
return '';
});
```#PaginatorCallback
```php
pagination = $pagination;
}public function __invoke(int $type, int $page): string
{
switch ($type)
{
case self::SEPARATOR_TYPE:
return '...';
case self::FIRST_PAGE_TYPE:
return '↞';
case self::PREVIOUS_PAGE_TYPE:
return 'Previous';
case self::PAGE_TYPE:
return ''.$page.'';
case self::CURRENT_PAGE_TYPE:
return ''.$page.'';
case self::NEXT_PAGE_TYPE:
return 'Next';
case self::LAST_PAGE_TYPE:
return '↠';
}
return '';
}
}
``````php
[
'active' => true,
'hidden' => false
],
'previous-next' => [
'active' => true,
'hidden' => false
]
]);echo $pagination->toHTML(new ExamplePaginatorCallback($pagination));
```