function ViewsThemeHooks::preprocessViewsViewUnformatted

Prepares variables for views unformatted rows templates.

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

Parameters

array $variables: An associative array containing:

  • view: The view object.
  • rows: An array of row items. Each row is an array of content.
1 call to ViewsThemeHooks::preprocessViewsViewUnformatted()
ViewsThemeHooks::preprocessViewsViewList in core/modules/views/src/Hook/ViewsThemeHooks.php
Prepares variables for Views HTML list templates.

File

core/modules/views/src/Hook/ViewsThemeHooks.php, line 1065

Class

ViewsThemeHooks
Hook implementations for views.

Namespace

Drupal\views\Hook

Code

public function preprocessViewsViewUnformatted(array &$variables) : void {
  $view = $variables['view'];
  $rows = $variables['rows'];
  $style = $view->style_plugin;
  $options = $style->options;
  $variables['default_row_class'] = !empty($options['default_row_class']);
  foreach ($rows as $id => $row) {
    $variables['rows'][$id] = [];
    $variables['rows'][$id]['content'] = $row;
    $variables['rows'][$id]['attributes'] = new Attribute();
    if ($row_class = $view->style_plugin
      ->getRowClass($id)) {
      $variables['rows'][$id]['attributes']->addClass($row_class);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.