Legacy Documentation
You are using the documentation for version 3.5.17. Go here for the latest version or check here for your available upgrades to the latest version.
CP/Pagination Service¶
Simple Example¶
Adding pagination to the control panel is a common task and we created a pagination service to assist. This service follows our style-guide handling all the mathematical calculations. All you need is the number of items you are going to paginate and a URL object:
$base_url = ee('CP/URL', 'publish/edit');
$pagination = ee('CP/Pagination', $total_count)
->render($base_url);
CP/Pagination Service Methods¶
-
class
EllisLab\ExpressionEngine\Library\CP\
Pagination
¶
-
EllisLab\ExpressionEngine\Library\CP\Pagination::
perPage
($per_page)¶ Sets the number of items per page
Parameters: - $per_page (int) – The number of items per page
Returns: $this
Return type: Pagination
-
EllisLab\ExpressionEngine\Library\CP\Pagination::
currentPage
($current_page)¶ Sets page number being displayed
Parameters: - $current_page (int) – The current page (defaults to 1)
Returns: $this
Return type: Pagination
-
EllisLab\ExpressionEngine\Library\CP\Pagination::
queryStringVariable
($page_variable)¶ Sets the query string variable name
Parameters: - $page_variable (string) – The name of the page variable in the query string (defaults to ‘page’)
Returns: $this
Return type: Pagination
-
EllisLab\ExpressionEngine\Library\CP\Pagination::
displayPageLinks
($pages_to_display)¶ Sets the number of numbered pages to calculate
Parameters: - $pages (int) – The number of numbered pages to calculate (defaults to 3)
Returns: $this
Return type: Pagination
-
EllisLab\ExpressionEngine\Library\CP\Pagination::
render
($base_url)¶ Renders the pagination to HTML
Parameters: - $base_url (Url) – A CPURL object
Returns: The rendered HTML of the pagination
Return type: string