Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fusic/flexlimitpagination
https://github.com/fusic/flexlimitpagination
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fusic/flexlimitpagination
- Owner: fusic
- Created: 2016-12-07T05:43:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T13:42:14.000Z (almost 8 years ago)
- Last Synced: 2024-12-11T11:12:58.212Z (about 1 month ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Flexpager plugin for CakePHP
maintainer: @gorogoroyasu## Installation
```
composer require fusic/Flexpager
```## discription
this plugin will help you to create the candidates of pagination.
ex)normal paginator
```
< prev 1 2 3 4 5 next >
```
this paginator
```
< prev 1 2 3 4 5 next> 10 20 100
```
the "10","20","100" means that the use of your application can change the paginate limit flexibly.## settings
first of all, you have to load the component.
and, you have to write "listCandidates" in `public $paginate`in controller
```public $paginate = [
'listCandidates' = [10, 20, 100],
// and more configs.
];
public function initialize()
{
parent::initialize();
$this->loadComponent('Flexpager.Flexpager');
}
```after that, you have to add this line to AppView.php
```
public function initialize()
{
parent::initialize();
$this->loadHelper('Flexpager.Flexpaginator');
}
```## usage
in controller (for example in index )
```
public function index()
{
$pages = $this->Flexpager->paginate($this->Pages);
$this->set(compact('pages'));
}
```in ctp (for example in index)
```
= $this->Flexpaginator->prev('< '.__('previous')) ?>
= $this->Flexpaginator->numbers() ?>
= $this->Flexpaginator->next(__('next').' >') ?>
= $this->Flexpaginator->limitCandidate() ?>
```the method limitCandidate() will return the list of candidates.
if you want to customize the template,
you can use the method below.```
= $this->Flexpaginator->setFlexPagerTemplate('{{content}}') ?>
```the args of this method have to include '{{url}}' and '{{content}}'.
the default template is `'{{content}}'`.
please note that `setFlexPagerTemplate` method should appear before the method `listCandidates`.