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.

OptionTypeDescription
numPageLinksintNumber of links that the pagination navigation should have, minimum 5
Default:10
getVarsarrayGet vars that should appear in the pagination, or leave empty and populate $input->whitelist (preferred)
Default:[]
baseUrlstringThe baseUrl from which the navigation item links will start
Default:''
pagePage or nullThe current Page, or leave NULL to autodetect
Default:null
listMarkupstringList container markup. Place {out} where you want the individual items rendered
Default:<ul class='{class}' aria-label='{aria-label}'>{out}</ul>
listClassstringClass attribute for the pagination list
Default:'MarkupPagerNav'
itemMarkupstringList item markup. Place '{class}' for item class (required), and '{out}' for item content
Default:<li aria-label='{aria-label}' class='{class}' {attr}>{out}</li>
separatorItemMarkupstring or nullItem separator "...", null makes it use the itemMarkup instead
Default:null
linkMarkupstringLink markup. Place '{url}' for href attribute, and '{out}' for label content
Default:<a href='{url}'><span>{out}</span></a>
currentLinkMarkupstringLink markup for current page. Place '{url}' for href attribute and '{out}' for label content
Default:<a href='{url}'><span>{out}</span></a>
nextItemLabelstringLabel used for the 'Next' button
Default:'Next'
previousItemLabelstringLabel used for the 'Previous' button
Default:'Prev'
separatorItemLabelstringLabel used in the separator item
Default:'…'
separatorItemClassstringClass used for list item separator
Default:'MarkupPagerNavSeparator'
firstItemClassstringClass used for first item
Default:'MarkupPagerNavFirst'
firstNumberItemClassstringClass used for first numbered nav item
Default:'MarkupPagerNavFirstNum'
nextItemClassstringClass used for "next" nav item
Default:'MarkupPagerNavNext'
previousItemClassstringClass used for "previous" nav item
Default:'MarkupPagerNavPrevious'
lastItemClassstringClass added to last nav item
Default:'MarkupPagerNavLast'
lastNumberItemClassstringClass added to last numbered nav item
Default:'MarkupPagerNavLastNum'
currentItemClassstringClass added to current/active nav item
Default:'MarkupPagerNavOn'
currentItemExtraAttrstringAny extra attributes for current item
Default:aria-current='true'
listAriaLabelstringAria label for list <ul>
Default:'Pagination links'
itemAriaLabelstringAria label for list item <li>
Default:'Page {n}'
currentItemAriaLabelstringAria label for current list item
Default:'Page {n}, current page'
nextItemAriaLabelstringAria label for "next" nav item
Default:'Next page'
previousItemAriaLabelstringAria label for "prev" nav item
Default:'Previous page'
lastItemAriaLabelstringAria 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>&hellip;</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

NameType(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