\Disco\classesPaginate

This class becomes available as the variable `page` inside {{ page }}{{ endpage}} tags in twig templates. It provides the functionality for creating navigation in paged content, as well as context awareness such as the current page and total pages.

Summary

Methods
Properties
Constants
__construct()
pageDoesNotExist()
getPageUrl()
getPrevUrls()
getNextUrls()
getAllUrls()
getRangeUrls()
getEasyMarkup()
$paginateUsed
$pageDoesNotExist
$totalItems
$limit
$currentPage
$total
$first
$last
$perPage
$totalDisplayed
$totalPages
$prevUrl
$nextUrl
$firstUrl
$currentUrl
$lastUrl
No constants found
No protected methods found
$format
N/A
fromFormat()
$uri
N/A

Properties

$paginateUsed

$paginateUsed : boolean

Type

boolean — Whether the request served actually used pagination or not.

$pageDoesNotExist

$pageDoesNotExist : boolean

Type

boolean — Whether the requested current page is out of bounds and doesn't exist.

$totalItems

$totalItems : integer

Type

integer — The total number of items in the result set.

$limit

$limit : integer

Type

integer — The limit used in the query.

$currentPage

$currentPage : integer

Type

integer — The current page being paginated.

$total

$total : integer

Type

integer — The total number of results/items available for pagination.

$first

$first : integer

Type

integer — The position of the first item in the paginated result set, ex: if you have 5 pages of 10 items each, and your on page 3, first will be 31.

$last

$last : integer

Type

integer — The position of the last item in the paginated result set, ex: if you have 5 pages of 10 items each, and your on page 5, last will be 60. If there were less items than the limit, then last will be that number, ex: your on page 5 but there are only 58 items, last will be 58 and not 60.

$perPage

$perPage : integer

Type

integer — The number of results per page.

$totalDisplayed

$totalDisplayed : integer

Type

integer — The number of results being displayed on the current page.

$totalPages

$totalPages : integer

Type

integer — The total number of pages for the paginated results.

$prevUrl

$prevUrl : null|string

Type

null|string — The url to the previous page in the paginated results.

$nextUrl

$nextUrl : null|string

Type

null|string — The url to the next page in the paginated results.

$firstUrl

$firstUrl : string

Type

string — The url to the first page in the paginated results.

$currentUrl

$currentUrl : string

Type

string — The url to the current page in the paginated results.

$lastUrl

$lastUrl : string

Type

string — The url to the last page in the paginated results.

$format

$format : string

Type

string — The pagination format as defined in `app/config/config.php` as key `paginate`, or by default `/page/{page}`. Must contain a `{page}` placeholder, which will be replaced with the current page.

$uri

$uri : string

Type

string — The current page URI.

Methods

__construct()

__construct(integer  $currentPage, integer  $totalItems, integer  $limit) 

From the passed arguements all public variables of this class can be derived and will be set.

Parameters

integer $currentPage

The current page being paginated.

integer $totalItems

The total items being paginated.

integer $limit

The limit used in the query for results to be paginated.

pageDoesNotExist()

pageDoesNotExist() 

Whether the current page exists in the result set, aka its not out of bounds. If the page being requested is page 3 and there are only 2 pages in the result set, then the page does not exist.

getPageUrl()

getPageUrl(integer  $page) : string

Get the url for a specified page number.

Parameters

integer $page

The page number to build a link to.

Returns

string

getPrevUrls()

getPrevUrls(null|integer  $floor = null) : array<mixed,string>

Get paginated urls that come before the current page.

Parameters

null|integer $floor

The max number of links to generate.

Returns

array<mixed,string>

getNextUrls()

getNextUrls(null|integer  $max = null) : array<mixed,string>

Get paginated urls that come after the current page.

Parameters

null|integer $max

The max number of links to generate.

Returns

array<mixed,string>

getAllUrls()

getAllUrls() : array<mixed,string>

Get all the urls for pages in the results.

Returns

array<mixed,string>

getRangeUrls()

getRangeUrls(integer  $start, integer  $end) : array<mixed,string>

Return the urls for the pages between `$start` and `$end`.

Parameters

integer $start

The page to start from.

integer $end

The page to end on.

Returns

array<mixed,string>

getEasyMarkup()

getEasyMarkup() : string

Get a simple markup for a pagination feed.

Returns

string —

The pagination markup.

fromFormat()

fromFormat(integer  $page) : string

Create the pagination portion of the URI for links using `$this->format`.

Parameters

integer $page

The page number to format.

Returns

string