function template_preprocess_views_view_list

template_preprocess_views_view_list(&$variables)

Prepares variables for Views HTML list templates.

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

Parameters

array $variables: An associative array containing:

  • view: A View object.

File

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

Code

function template_preprocess_views_view_list(&$variables) {
  $handler = $variables['view']->style_plugin;

  // Fetch classes from handler options.
  if ($handler->options['class']) {
    $class = explode(' ', $handler->options['class']);
    $class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class);

    // Initialize a new attribute class for $class.
    $variables['list']['attributes'] = new Attribute(array('class' => $class));
  }

  // Fetch wrapper classes from handler options.
  if ($handler->options['wrapper_class']) {
    $wrapper_class = explode(' ', $handler->options['wrapper_class']);
    $variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class);
  }

  $variables['list']['type'] = $handler->options['type'];

  template_preprocess_views_view_unformatted($variables);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views!views.theme.inc/function/template_preprocess_views_view_list/8.1.x