function _views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal in Views Bootstrap 7.3
Further preprocessing for horizontal alignment.
See also
_views_bootstrap_preprocess_views_style_plugin_prepare_grid()
1 call to _views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal()
- _views_bootstrap_preprocess_views_style_plugin_prepare_grid in ./
views_bootstrap.module - View preprocessing that prepares the results as a Bootstrap grid.
File
- ./
views_bootstrap.module, line 129 - Bootstrap integration.
Code
function _views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal(&$vars) {
$options = $vars['view']->style_plugin->options;
// If columns are set to 0 (Auto), apply the maximum from the number of columns
// defined per device size.
if (!$options['columns_horizontal']) {
$options['columns_horizontal'] = 1;
foreach (array(
'xs',
'sm',
'md',
'lg',
) as $size) {
if (isset($options["columns_{$size}"]) && $options["columns_{$size}"] > 0) {
$tmpColumns = 12 / $options["columns_{$size}"];
if ($tmpColumns > $options['columns_horizontal']) {
$options['columns_horizontal'] = $tmpColumns;
}
}
}
}
// Distribute items in rows and columns.
$vars['items'] = _views_bootstrap_split_rows_horizontal($vars['rows'], $options['columns_horizontal']);
// If the number of columns is set to -1 ("Single row" option), calculate the
// number of columns after which the clearfix divs should be placed for each
// screen size. No clearfix is necessary for large screens (lg) and when the
// size of the column is 12 (full row).
if ($options['columns_horizontal'] == -1) {
$vars['clearfix'] = array();
foreach (array(
'xs',
'sm',
'md',
'lg',
) as $size) {
if (!empty($options["columns_{$size}"]) && $options["columns_{$size}"] != 12) {
$vars['clearfix'][$size] = 12 / $options["columns_{$size}"];
}
}
}
}