You are here

function template_preprocess_views_slideshow_pager_fields in Views Slideshow 8.4

Same name and namespace in other branches
  1. 8.3 views_slideshow.theme.inc \template_preprocess_views_slideshow_pager_fields()
  2. 6.3 views_slideshow.module \template_preprocess_views_slideshow_pager_fields()
  3. 7.3 theme/views_slideshow.theme.inc \template_preprocess_views_slideshow_pager_fields()

Theme pager fields.

Related topics

File

./views_slideshow.theme.inc, line 225
The theme system, which controls the output of views slideshow.

Code

function template_preprocess_views_slideshow_pager_fields(&$vars) {

  // Add JavaScript settings for the field.
  $vars['#attached']['library'][] = 'views_slideshow/widget_info';
  $vars['#attached']['drupalSettings']['viewsSlideshowPagerFields'][$vars['vss_id']] = [
    $vars['location'] => [
      'activatePauseOnHover' => $vars['settings']['views_slideshow_pager_fields']['views_slideshow_pager_fields_hover'],
    ],
  ];

  // Add hover intent library.
  if ($vars['settings']['views_slideshow_pager_fields']['views_slideshow_pager_fields_hover']) {
    $vars['#attached']['library'][] = 'views_slideshow/jquery_hoverIntent';
  }
  $vars['widget_id'] = $vars['attributes']['id'];

  // Add our class to the wrapper.
  $vars['attributes']['class'][] = 'views_slideshow_pager_field';

  // Render all the fields unless there is only 1 slide and the user specified
  // to hide them when there is only one slide.
  $vars['rendered_field_items'] = [];
  foreach ($vars['view']->result as $count => $node) {
    $rendered_fields = [];
    foreach ($vars['settings']['views_slideshow_pager_fields']['views_slideshow_pager_fields_fields'] as $field => $use) {
      if ($use !== 0 && is_object($vars['view']->field[$field])) {
        $rendered_fields[] = [
          '#theme' => $vars['view']
            ->buildThemeFunctions('views_slideshow_pager_field_field'),
          '#view' => $vars['view'],
          '#label' => $vars['view']->field[$field]->options['label'],
          '#output' => $vars['view']->style_plugin
            ->getField($count, $field),
          '#css_identifier' => Html::cleanCssIdentifier($vars['view']->field[$field]->field),
        ];
      }
    }
    $vars['rendered_field_items'][] = [
      '#theme' => $vars['view']
        ->buildThemeFunctions('views_slideshow_pager_field_item'),
      '#vss_id' => $vars['vss_id'],
      '#item' => $rendered_fields,
      '#count' => $count,
      '#location' => $vars['location'],
      '#length' => count($vars['view']->result),
    ];
  }
}