template_preprocess_views_mini_pager(&$variables)
Prepares variables for views mini-pager templates.
Default template: views-mini-pager.html.twig.
Parameters
array $variables: An associative array containing:
- tags: Provides link text for the next/previous links.
- element: The pager's id.
- parameters: Any extra GET parameters that should be retained, such as exposed input.
File
- core/modules/views/views.theme.inc, line 1014
- Preprocessors and helper functions to make theming easier.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | function template_preprocess_views_mini_pager(& $variables ) { global $pager_page_array , $pager_total ; $tags = & $variables [ 'tags' ]; $element = $variables [ 'element' ]; $parameters = $variables [ 'parameters' ]; // Current is the page we are currently paged to. $variables [ 'items' ][ 'current' ] = $pager_page_array [ $element ] + 1; if ( $pager_total [ $element ] > 1 && $pager_page_array [ $element ] > 0) { $options = array ( 'query' => pager_query_add_page( $parameters , $element , $pager_page_array [ $element ] - 1), ); $variables [ 'items' ][ 'previous' ][ 'href' ] = \Drupal::url( '<current>' , [], $options ); if (isset( $tags [1])) { $variables [ 'items' ][ 'previous' ][ 'text' ] = $tags [1]; } $variables [ 'items' ][ 'previous' ][ 'attributes' ] = new Attribute(); } if ( $pager_page_array [ $element ] < ( $pager_total [ $element ] - 1)) { $options = array ( 'query' => pager_query_add_page( $parameters , $element , $pager_page_array [ $element ] + 1), ); $variables [ 'items' ][ 'next' ][ 'href' ] = \Drupal::url( '<current>' , [], $options ); if (isset( $tags [3])) { $variables [ 'items' ][ 'next' ][ 'text' ] = $tags [3]; } $variables [ 'items' ][ 'next' ][ 'attributes' ] = new Attribute(); } // This is based on the entire current query string. We need to ensure // cacheability is affected accordingly. $variables [ '#cache' ][ 'contexts' ][] = 'url.query_args' ; } |
Please login to continue.