pager_query_add_page(array $query, $element, $index)
Gets the URL query parameter array of a pager link.
Adds to or adjusts the 'page' URL query parameter so that if you follow the link, you'll get page $index for pager $element on the page.
The 'page' URL query parameter is a comma-delimited string, where each value is the target content page for the corresponding pager $element. For instance, if we have 5 pagers on a single page, and we want to have a link to a page that should display the 6th content page for the 3rd pager, and the 1st content page for all the other pagers, then the URL query will look like this: ?page=0,0,5,0,0 (page numbering starts at zero).
Parameters
array $query: An associative array of URL query parameters to add to.
int $element: An integer to distinguish between multiple pagers on one page.
int $index: The index of the target page, for the given element, in the pager array.
Return value
array The altered $query parameter array.
File
- core/includes/pager.inc, line 311
- Functions to aid in presenting database results as a set of pages.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | function pager_query_add_page( array $query , $element , $index ) { global $pager_page_array ; // Build the 'page' query parameter. This is built based on the current // page of each pager element (or NULL if the pager is not set), with the // exception of the requested page index for the current element. $max_element = max( array_keys ( $pager_page_array )); $element_pages = []; for ( $i = 0; $i <= $max_element ; $i ++) { $element_pages [] = ( $i == $element ) ? $index : (isset( $pager_page_array [ $i ]) ? $pager_page_array [ $i ] : NULL); } $query [ 'page' ] = implode( ',' , $element_pages ); // Merge the query parameters passed to this function with the parameters // from the current request. In case of collision, the parameters passed into // this function take precedence. if ( $current_request_query = pager_get_query_parameters()) { $query = array_merge ( $current_request_query , $query ); } return $query ; } |
Please login to continue.