You are here

function template_preprocess_views_bootstrap_grid in Views Bootstrap 8.3

Same name and namespace in other branches
  1. 8.4 views_bootstrap.theme.inc \template_preprocess_views_bootstrap_grid()

Prepares variables for views grid templates.

Default template: views-bootstrap-grid.html.twig.

Parameters

array $vars: An associative array containing:

  • view: A ViewExecutable object.
  • rows: The raw row data.
1 string reference to 'template_preprocess_views_bootstrap_grid'
ViewsBootstrap::getThemeHooks in src/ViewsBootstrap.php
Returns the theme hook definition information.

File

./views_bootstrap.theme.inc, line 190
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_views_bootstrap_grid(array &$vars) {
  $view = $vars['view'];
  $vars['id'] = ViewsBootstrap::getUniqueId($view);
  $vars['attributes']['class'][] = 'grid';
  $options = $view->style_plugin->options;
  $options['automatic_width'] = [
    'default' => FALSE,
  ];
  foreach ([
    'xs',
    'sm',
    'md',
    'lg',
  ] as $size) {
    $vars["col_" . $size] = $options["col_" . $size];

    // Get the value from the size sting.
    $vars['sizes'][$size] = ViewsBootstrap::getColSize($options["col_" . $size]);
  }
  $vars['options'] = $options;
}