Pagination
extends Plugin
in package
implements
IteratorAggregate, JsonSerializable
Pagination accepts a pagination object generated by the Builder system to create a loopable set of objects you can include in a template.
$builder = $this->getDI()->getArticleManager()->getBuilder()
->setPage($page)
->setLimit($perPage)
->byTags($section->tags)
->paginate();
$articles = $builder->getItems();
$paginator = (new Pagination)
->setPagination($builder->getPagination())
->setLimit($perPage)
->build();
Then in your template
{% for page in paginator %}
<a href="{{ page.url }}">{{ page.label }}</a>
{% endfor %}
Interfaces, Classes and Traits
- IteratorAggregate
- JsonSerializable
Table of Contents
- $allLinks : mixed
- $built : mixed
- $first : mixed
- $last : mixed
- $limit : mixed
- $next : mixed
- $pages : mixed
- $pagination : mixed
- $params : mixed
- $placeholders : mixed
- $previous : mixed
- $show : mixed
- $url : mixed
- __construct() : mixed
- Create new paginator If no url is provided, will use current.
- build() : self
- Build pagination. Called automatically on first attempt to access pages
- getFirst() : object
- Get first page
- getIterator() : ArrayIterator
- Allow for iterator access
- getLast() : object
- Get last page
- getNext() : object
- Get next page
- getPages() : array<string|int, mixed>
- Get all numbered pages, e.g. not first/last and next/previous
- getPrevious() : object
- Get previous page
- jsonSerialize() : array<string|int, mixed>
- Allow for proper JSON serialization
- rebuild() : self
- Force a rebuild of pagination. Really only useful if you reset the pagination object or url options after building
- setLimit() : self
- Set the number of items per page
- setPagination() : self
- Set the pagination object
- setParams() : self
- Set extra query params, note that reserved words will be unset
- setShow() : self
- Set number of pages to show for sliding pagination
- setUrl() : self
- Set the base pagination URL. Will substitute page and per_page attributes
Properties
$allLinks
private
mixed
$allLinks
$built
private
mixed
$built
= false
$first
private
mixed
$first
$last
private
mixed
$last
$limit
private
mixed
$limit
= null
$next
private
mixed
$next
$pages
private
mixed
$pages
$pagination
private
mixed
$pagination
$params
private
mixed
$params
$placeholders
private
mixed
$placeholders
$previous
private
mixed
$previous
$show
private
mixed
$show
= 10
$url
private
mixed
$url
Methods
__construct()
Create new paginator If no url is provided, will use current.
public
__construct([mixed $pagination = [] ][, mixed $url = false ]) : mixed
Parameters
- $pagination : mixed = []
- $url : mixed = false
Return values
mixed —build()
Build pagination. Called automatically on first attempt to access pages
public
build() : self
Return values
self —getFirst()
Get first page
public
getFirst() : object
Return values
object —Ceo\Pagination\Url
getIterator()
Allow for iterator access
public
getIterator() : ArrayIterator
Return values
ArrayIterator —getLast()
Get last page
public
getLast() : object
Return values
object —Ceo\Pagination\Url
getNext()
Get next page
public
getNext() : object
Return values
object —Ceo\Pagination\Url
getPages()
Get all numbered pages, e.g. not first/last and next/previous
public
getPages() : array<string|int, mixed>
Return values
array<string|int, mixed> —of Ceo\Pagination\Url
getPrevious()
Get previous page
public
getPrevious() : object
Return values
object —Ceo\Pagination\Url
jsonSerialize()
Allow for proper JSON serialization
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —rebuild()
Force a rebuild of pagination. Really only useful if you reset the pagination object or url options after building
public
rebuild() : self
Return values
self —setLimit()
Set the number of items per page
public
setLimit(mixed $limit) : self
Parameters
- $limit : mixed
Return values
self —setPagination()
Set the pagination object
public
setPagination(stdClass $pagination) : self
Parameters
- $pagination : stdClass
Return values
self —setParams()
Set extra query params, note that reserved words will be unset
public
setParams([mixed $params = [] ]) : self
Parameters
- $params : mixed = []
Return values
self —setShow()
Set number of pages to show for sliding pagination
public
setShow(int $pages) : self
Parameters
- $pages : int
Return values
self —setUrl()
Set the base pagination URL. Will substitute page and per_page attributes
public
setUrl(mixed $url) : self
Parameters
- $url : mixed