CodeIgniter v4.6 API

PagerRenderer
in package

Class PagerRenderer

This class is passed to the view that describes the pagination, and is used to get the link information and provide utility methods needed to work with pagination.

Tags
see
PagerRendererTest

Table of Contents

Properties

$current  : int
Current page number.
$first  : int
First page number in the set of links to be displayed.
$last  : int
Last page number in the set of links to be displayed.
$pageCount  : int
Total number of pages.
$pageSelector  : string
Name of $_GET parameter
$perPage  : int|null
Returns the number of results per page that should be shown.
$perPageEnd  : int|null
The number of items the page ends with.
$perPageStart  : int|null
The number of items the page starts with.
$segment  : int
Segment number used for pagination.
$total  : int
Total number of items.
$uri  : URI
URI base for pagination links

Methods

__construct()  : mixed
Constructor.
getCurrent()  : string
Returns the URI of the current page.
getCurrentPageNumber()  : int
Returns the page number of the current page.
getFirst()  : string
Returns the URI of the first page.
getFirstPageNumber()  : int
Returns the page number of the first page in the set of links to be displayed.
getLast()  : string
Returns the URI of the last page.
getLastPageNumber()  : int
Returns the page number of the last page in the set of links to be displayed.
getNext()  : string|null
Returns a URL to the "next" page. The next page is NOT, the page after the current page, but is the page that follows the "last" page.
getNextPage()  : string|null
Returns a URL to the "next" page.
getNextPageNumber()  : int|null
Returns the next page number.
getPageCount()  : int
Returns total number of pages.
getPerPage()  : int|null
Returns the number of items to be displayed on the page.
getPerPageEnd()  : int|null
Returns the number of items the page ends with.
getPerPageStart()  : int|null
Returns the number of items the page starts with.
getPrevious()  : string|null
Returns a URL to the "previous" page. The previous page is NOT the page before the current page, but is the page just before the "first" page.
getPreviousPage()  : string|null
Returns a URL to the "previous" page.
getPreviousPageNumber()  : int|null
Returns the previous page number.
getTotal()  : int|null
Returns the total items of the page.
hasNext()  : bool
Checks to see if there is a "next" page after our "last" page.
hasNextPage()  : bool
Checks to see if there is a "next" page after our "last" page.
hasPrevious()  : bool
Checks to see if there is a "previous" page before our "first" page.
hasPreviousPage()  : bool
Checks to see if there is a "previous" page before our "first" page.
links()  : array<int, array{uri: string, title: int, active: bool}>
Returns an array of links that should be displayed. Each link is represented by another array containing of the URI the link should go to, the title (number) of the link, and a boolean value representing whether this link is active or not.
setSurroundCount()  : PagerRenderer
Sets the total number of links that should appear on either side of the current page. Adjusts the first and last counts to reflect it.
updatePages()  : void
Updates the first and last pages based on $surroundCount, which is the number of links surrounding the active page to show.
updatePerPages()  : void
Updates the start and end items per pages, which is the number of items displayed on the active page.

Properties

$first

First page number in the set of links to be displayed.

protected int $first

$last

Last page number in the set of links to be displayed.

protected int $last

$pageSelector

Name of $_GET parameter

protected string $pageSelector

$perPage

Returns the number of results per page that should be shown.

protected int|null $perPage

$perPageEnd

The number of items the page ends with.

protected int|null $perPageEnd = null

$perPageStart

The number of items the page starts with.

protected int|null $perPageStart = null

$segment

Segment number used for pagination.

protected int $segment

Methods

__construct()

Constructor.

public __construct(array<string|int, mixed> $details) : mixed
Parameters
$details : array<string|int, mixed>

getCurrent()

Returns the URI of the current page.

public getCurrent() : string
Return values
string

getCurrentPageNumber()

Returns the page number of the current page.

public getCurrentPageNumber() : int
Return values
int

getFirst()

Returns the URI of the first page.

public getFirst() : string
Return values
string

getFirstPageNumber()

Returns the page number of the first page in the set of links to be displayed.

public getFirstPageNumber() : int
Return values
int

getLast()

Returns the URI of the last page.

public getLast() : string
Return values
string

getLastPageNumber()

Returns the page number of the last page in the set of links to be displayed.

public getLastPageNumber() : int
Return values
int

getNext()

Returns a URL to the "next" page. The next page is NOT, the page after the current page, but is the page that follows the "last" page.

public getNext() : string|null
Return values
string|null

getNextPage()

Returns a URL to the "next" page.

public getNextPage() : string|null

You MUST call hasNextPage() first, or this value may be invalid.

Return values
string|null

getNextPageNumber()

Returns the next page number.

public getNextPageNumber() : int|null
Return values
int|null

getPageCount()

Returns total number of pages.

public getPageCount() : int
Return values
int

getPerPage()

Returns the number of items to be displayed on the page.

public getPerPage() : int|null
Return values
int|null

getPerPageEnd()

Returns the number of items the page ends with.

public getPerPageEnd() : int|null
Return values
int|null

getPerPageStart()

Returns the number of items the page starts with.

public getPerPageStart() : int|null
Return values
int|null

getPrevious()

Returns a URL to the "previous" page. The previous page is NOT the page before the current page, but is the page just before the "first" page.

public getPrevious() : string|null
Return values
string|null

getPreviousPage()

Returns a URL to the "previous" page.

public getPreviousPage() : string|null

You MUST call hasPreviousPage() first, or this value may be invalid.

Return values
string|null

getPreviousPageNumber()

Returns the previous page number.

public getPreviousPageNumber() : int|null
Return values
int|null

getTotal()

Returns the total items of the page.

public getTotal() : int|null
Return values
int|null

hasNext()

Checks to see if there is a "next" page after our "last" page.

public hasNext() : bool
Return values
bool

hasNextPage()

Checks to see if there is a "next" page after our "last" page.

public hasNextPage() : bool
Return values
bool

hasPrevious()

Checks to see if there is a "previous" page before our "first" page.

public hasPrevious() : bool
Return values
bool

hasPreviousPage()

Checks to see if there is a "previous" page before our "first" page.

public hasPreviousPage() : bool
Return values
bool

Returns an array of links that should be displayed. Each link is represented by another array containing of the URI the link should go to, the title (number) of the link, and a boolean value representing whether this link is active or not.

public links() : array<int, array{uri: string, title: int, active: bool}>
Return values
array<int, array{uri: string, title: int, active: bool}>

setSurroundCount()

Sets the total number of links that should appear on either side of the current page. Adjusts the first and last counts to reflect it.

public setSurroundCount([int|null $count = null ]) : PagerRenderer
Parameters
$count : int|null = null
Return values
PagerRenderer

updatePages()

Updates the first and last pages based on $surroundCount, which is the number of links surrounding the active page to show.

protected updatePages([int|null $count = null ]) : void
Parameters
$count : int|null = null

The new "surroundCount"

updatePerPages()

Updates the start and end items per pages, which is the number of items displayed on the active page.

protected updatePerPages() : void

        
On this page

Search results