function template_preprocess_views_view_summary

Prepares variables for views summary templates.

The summary prints a single record from a row, with fields.

Default template: views-view-summary.html.twig.

Parameters

array $vars: An associative array containing:

File

drupal/core/modules/views/views.theme.inc, line 414
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_views_view_summary(&$vars) {
  $view = $vars['view'];
  $argument = $view->argument[$view->build_info['summary_level']];
  $vars['row_classes'] = array();
  $url_options = array();
  if (!empty($view->exposed_raw_input)) {
    $url_options['query'] = $view->exposed_raw_input;
  }
  $active_urls = drupal_map_assoc(array(
    url(current_path(), array(
      'alias' => TRUE,
    )),
    // force system path
    url(current_path()),
  ));

  // Collect all arguments foreach row, to be able to alter them for example
  // by the validator. This is not done per single argument value, because this
  // could cause performance problems.
  $row_args = array();
  foreach ($vars['rows'] as $id => $row) {
    $row_args[$id] = $argument
      ->summaryArgument($row);
  }
  $argument
    ->processSummaryArguments($row_args);
  foreach ($vars['rows'] as $id => $row) {
    $vars['rows'][$id]->link = $argument
      ->summaryName($row);
    $args = $view->args;
    $args[$argument->position] = $row_args[$id];
    $base_path = NULL;
    if (!empty($argument->options['summary_options']['base_path'])) {
      $base_path = $argument->options['summary_options']['base_path'];
    }
    $vars['rows'][$id]->url = url($view
      ->getUrl($args, $base_path), $url_options);
    $vars['rows'][$id]->count = intval($row->{$argument->count_alias});
    $vars['row_classes'][$id] = array();
    if (isset($active_urls[$vars['rows'][$id]->url])) {
      $vars['row_classes'][$id]['class'][] = 'active';
    }
    $vars['row_classes'][$id] = new Attribute($vars['row_classes'][$id]);
  }
}