function pager_find_page in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/pager.inc \pager_find_page()
Returns the current page being requested for display within a pager.
Parameters
int $element: (optional) An integer to distinguish between multiple pagers on one page.
Return value
int The number of the current requested page, within the pager represented by $element. This is determined from the URL query parameter \Drupal::request()->query->get('page'), or 0 by default. Note that this number may differ from the actual page being displayed. For example, if a search for "example text" brings up three pages of results, but a user visits search/node/example+text?page=10, this function will return 10, even though the default pager implementation adjusts for this and still displays the third page of search results at that URL.
See also
3 calls to pager_find_page()
- PagersCacheContext::getContext in core/
lib/ Drupal/ Core/ Cache/ Context/ PagersCacheContext.php - pager_default_initialize in core/
includes/ pager.inc - Initializes a pager.
- QueryBase::initializePager in core/
lib/ Drupal/ Core/ Entity/ Query/ QueryBase.php - Gets the total number of results and initialize a pager for the query.
File
- core/
includes/ pager.inc, line 28 - Functions to aid in presenting database results as a set of pages.
Code
function pager_find_page($element = 0) {
$page = \Drupal::request()->query
->get('page', '');
$page_array = explode(',', $page);
if (!isset($page_array[$element])) {
$page_array[$element] = 0;
}
return (int) $page_array[$element];
}