Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kejawenlab/ci4pager
Simple and Flexible Pagination Library for CodeIgniter 4
https://github.com/kejawenlab/ci4pager
codeigniter codeigniter-library codeigniter-pagination codeigniter4 codeigniter4-library pagination
Last synced: 2 months ago
JSON representation
Simple and Flexible Pagination Library for CodeIgniter 4
- Host: GitHub
- URL: https://github.com/kejawenlab/ci4pager
- Owner: KejawenLab
- Created: 2019-07-16T07:56:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-18T01:22:25.000Z (about 4 years ago)
- Last Synced: 2024-10-11T07:23:45.122Z (2 months ago)
- Topics: codeigniter, codeigniter-library, codeigniter-pagination, codeigniter4, codeigniter4-library, pagination
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 5
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CodeIgniter 4 Pagination Library
Simple and Flexible Pagination Library for CodeIgniter 4
## Requirement
* PHP 7.2 or above
* CodeIgniter v4
## Installation
`composer req kejawenlab/ci4pager`
## Usage
* From Query Result
```php
// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;$results = $db->query('SELECT * FROM users');
$page = 1;$paginator = Paginator::createFromResult($results, $page);
echo view('records', ['paginator' => $paginator]);
//In your view
foreach ($paginator->getResults() as $result) {
//your result here
}kejawenlab_ci4_pager($paginator, [
'base_url' => 'http://base_url.com/users',
'current_text' => 'Current Page',
'total_text' => 'Total Records',
]);
```* From Query Builder
```php
// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;$queryBuilder = $db->table('users');
$page = 1;$paginator = Paginator::createFromQueryBuilder($queryBuilder, $page);
echo view('records', ['paginator' => $paginator]);
//In your view
foreach ($paginator->getResults() as $result) {
//your result here
}kejawenlab_ci4_pager($paginator, [
'base_url' => 'http://base_url.com/users',
'current_text' => 'Current Page',
'total_text' => 'Total Records',
]);
```* From Array
```php
// In your controller
use KejawenLab\CodeIgniter\Pagination\Paginator;$results = $db->table('users')->get()->getResultArray();
$page = 1;$paginator = Paginator::createFromArray($results, $page);
echo view('records', ['paginator' => $paginator]);
//In your view
foreach ($paginator->getResults() as $result) {
//your result here
}kejawenlab_ci4_pager($paginator, [
'base_url' => 'http://base_url.com/users',
'current_text' => 'Current Page',
'total_text' => 'Total Records',
]);
```## Config Available
* `base_url`: required
* `current_text`: required
* `total_text`: required
* `use_get_param`: optional (default: true)
* `page_param`: when use `use_get_param` (default: page)
* `first_link_attr`: extra markup for first link (ex: `class="btn btn-success" id="first-page"`)
* `previous_link_attr`: extra markup for previous link
* `current_link_attr`: extra markup for current link
* `next_link_attr`: extra markup for next link
* `last_link_attr`: extra markup for last link
* `template_path`: optional (default: [template.tpl](src/template.tpl))