function template_preprocess_views_view_grid_responsive

Same name in other branches
  1. 11.x core/modules/views/views.theme.inc \template_preprocess_views_view_grid_responsive()

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 814

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;
}

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