You are here

function template_preprocess_views_view_grid_responsive in Drupal 10

Prepares variables for views grid - responsive style templates.

Default template: views-view-grid-responsive.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.

File

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

Code

function template_preprocess_views_view_grid_responsive(&$variables) {
  $variables['options'] = $variables['view']->style_plugin->options;
  $view = $variables['view'];
  $items = [];
  foreach ($variables['rows'] as $id => $item) {
    $attribute = new Attribute();
    if ($row_class = $view->style_plugin
      ->getRowClass($id)) {
      $attribute
        ->addClass($row_class);
    }
    $items[$id] = [
      'content' => $item,
      'attributes' => $attribute,
    ];
  }
  $variables['items'] = $items;
}