You are here

function _views_bootstrap_preprocess_views_style_plugin_prepare_grid in Views Bootstrap 7.3

View preprocessing that prepares the results as a Bootstrap grid.

Depending on the options selected on the style plugin handler, this function distributes the results into rows and columns, calculates where clearfix divs should be added (if applicable), and prepares the bootstrap classes that should be added to each column.

Used by the Bootstrap Grid and Bootstrap Thumbnail plugins.

See also

template_preprocess_views_bootstrap_grid_plugin_style()

template_preprocess_views_bootstrap_thumbnail_plugin_style()

2 calls to _views_bootstrap_preprocess_views_style_plugin_prepare_grid()
template_preprocess_views_bootstrap_grid_plugin_style in templates/grid/theme.inc
Implementation of template preprocess for the view.
template_preprocess_views_bootstrap_thumbnail_plugin_style in templates/thumbnail/theme.inc
Implementation of template preprocess for the view.

File

./views_bootstrap.module, line 103
Bootstrap integration.

Code

function _views_bootstrap_preprocess_views_style_plugin_prepare_grid(&$vars) {
  $options = $vars['view']->style_plugin->options;

  // Prepare column css classes. Add the class for each device size if set and if
  // different than 0 ("Do not define" option).
  $col_classes = explode(' ', $options['column_class']);
  foreach (array(
    'xs',
    'sm',
    'md',
    'lg',
  ) as $size) {
    if (!empty($options["columns_{$size}"])) {
      $col_classes[] = 'col-' . $size . '-' . $options["columns_{$size}"];
    }
  }
  $vars['col_classes'] = implode(' ', $col_classes);
  if ($options['alignment'] === 'horizontal') {
    _views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal($vars);
    return;
  }
  _views_bootstrap_preprocess_views_style_plugin_prepare_grid_vertical($vars);
}