PageArray::renderPagination()
Render pagination markup for this PageArray
This is an alias of the renderPager() method.
Use the $options argument to customize the output.
List of all options
Below is a list of all available customization options for the renderPager() and renderPagination() methods in PageArray and PaginatedArray.
| Option | Type | Description |
|---|---|---|
numPageLinks | int | Number of links that the pagination navigation should have, minimum 5 Default:10 |
getVars | array | Get vars that should appear in the pagination, or leave empty and populate $input->whitelist (preferred) Default:[] |
baseUrl | string | The baseUrl from which the navigation item links will start Default:'' |
page | Page or null | The current Page, or leave NULL to autodetect Default:null |
listMarkup | string | List container markup. Place {out} where you want the individual items rendered Default: <ul class='{class}' aria-label='{aria-label}'>{out}</ul> |
listClass | string | Class attribute for the pagination list Default:'MarkupPagerNav' |
itemMarkup | string | List item markup. Place '{class}' for item class (required), and '{out}' for item content Default: <li aria-label='{aria-label}' class='{class}' {attr}>{out}</li> |
separatorItemMarkup | string or null | Item separator "...", null makes it use the itemMarkup instead Default:null |
linkMarkup | string | Link markup. Place '{url}' for href attribute, and '{out}' for label content Default: <a href='{url}'><span>{out}</span></a> |
currentLinkMarkup | string | Link markup for current page. Place '{url}' for href attribute and '{out}' for label content Default: <a href='{url}'><span>{out}</span></a> |
nextItemLabel | string | Label used for the 'Next' button Default:'Next' |
previousItemLabel | string | Label used for the 'Previous' button Default:'Prev' |
separatorItemLabel | string | Label used in the separator item Default:'…' |
separatorItemClass | string | Class used for list item separator Default:'MarkupPagerNavSeparator' |
firstItemClass | string | Class used for first item Default:'MarkupPagerNavFirst' |
firstNumberItemClass | string | Class used for first numbered nav item Default:'MarkupPagerNavFirstNum' |
nextItemClass | string | Class used for "next" nav item Default:'MarkupPagerNavNext' |
previousItemClass | string | Class used for "previous" nav item Default:'MarkupPagerNavPrevious' |
lastItemClass | string | Class added to last nav item Default:'MarkupPagerNavLast' |
lastNumberItemClass | string | Class added to last numbered nav item Default:'MarkupPagerNavLastNum' |
currentItemClass | string | Class added to current/active nav item Default:'MarkupPagerNavOn' |
currentItemExtraAttr | string | Any extra attributes for current item Default: aria-current='true' |
listAriaLabel | string | Aria label for list <ul>Default:'Pagination links' |
itemAriaLabel | string | Aria label for list item <li>Default:'Page {n}' |
currentItemAriaLabel | string | Aria label for current list item Default:'Page {n}, current page' |
nextItemAriaLabel | string | Aria label for "next" nav item Default:'Next page' |
previousItemAriaLabel | string | Aria label for "prev" nav item Default:'Previous page' |
lastItemAriaLabel | string | Aria label for last nav item Default:'Page {n}, last page' |
Note: if you intend to render pagination more than once on in the output (such as above and below a list of products) then render pagination to a variable first, and then output it before rendering the products, and again after.
Available since version 3.0.260. Use renderPager() in prior versions, which has identical behavior and options.
Example
// find products
$products = $pages->find("parent=/products/, sort=name, limit=10");
// render products
foreach($products as $p) {
echo "<p><a href='$p->url'>$p->title</a><br>$p->summary</p>";
}
// render pagination
echo $products->renderPagination([
'numPageLinks' => 5,
'nextItemLabel' => "Next <span data-uk-pagination-next></span>",
'nextItemClass' => '',
'previousItemLabel' => "<span data-uk-pagination-previous></span> Prev"),
'previousItemClass' => '',
'lastItemClass' => '',
'currentItemClass' => 'uk-active',
'separatorItemLabel' => '<span>…</span>',
'separatorItemClass' => 'uk-disabled',
'listMarkup' => "<ul class='uk-pagination'>{out}</ul>",
'itemMarkup' => "<li class='{class}'>{out}</li>",
'linkMarkup' => "<a href='{url}'>{out}</a>",
'currentLinkMarkup' => "<span><a href='{url}'>{out}</a></span>",
'baseUrl' => $page->url(),
]); Usage
// basic usage
$string = $pageArray->renderPagination();
// usage with all arguments
$string = $pageArray->renderPagination(array $options = []);Arguments
| Name | Type(s) | Description |
|---|---|---|
$options (optional) | array | Options to modify default markup, classes, labels, etc. |
Return value
string
PageArray methods and properties
API reference based on ProcessWire core version 3.0.261