function template_preprocess_entity_pager in Entity Pager 8
Same name and namespace in other branches
- 7 entity_pager.module \template_preprocess_entity_pager()
- 2.0.x entity_pager.module \template_preprocess_entity_pager()
Prepares variables for entity pager templates.
Default template: entity-pager.html.twig.
Parameters
array $variables: An associative array containing:
- view: The view of the entity pager.
File
- ./
entity_pager.module, line 42 - Provides Next and Previous navigation on entities.
Code
function template_preprocess_entity_pager(array &$variables) {
$options = $variables['view']->style_plugin->options;
/** @var \Drupal\entity_pager\EntityPagerFactory $factory */
$factory = \Drupal::service('entity_pager.factory');
$entityPager = $factory
->get($variables['view'], $options);
$variables['links'] = $entityPager
->getLinks();
$variables['count_word'] = $entityPager
->getCountWord();
$variables['#attached']['library'][] = 'entity_pager/entity-pager';
$variables['#cache']['contexts'][] = 'url.path';
}