function apachesolr_pager_init in Apache Solr Search 5.2
Same name and namespace in other branches
- 6 apachesolr.module \apachesolr_pager_init()
- 6.2 apachesolr.module \apachesolr_pager_init()
Initialize a pager for theme('pager') without running an SQL query.
Parameters
$total: The total number of items found.
$limit: The number of items you will display per page.
$element: An optional integer to distinguish between multiple pagers on one page.
Return value
The current page for $element. 0 by default if $_GET['page'] is empty.
See also
1 call to apachesolr_pager_init()
File
- ./
apachesolr.module, line 1100 - Integration with the Apache Solr search application.
Code
function apachesolr_pager_init($total, $limit = 10, $element = 0) {
global $pager_page_array, $pager_total, $pager_total_items;
$page = isset($_GET['page']) ? $_GET['page'] : '';
// Convert comma-separated $page to an array, used by other functions.
$pager_page_array = explode(',', $page);
// We calculate the total of pages as ceil(items / limit).
$pager_total_items[$element] = $total;
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
$pager_page_array[$element] = max(0, min((int) $pager_page_array[$element], (int) $pager_total[$element] - 1));
return $pager_page_array[$element];
}