function _views_bootstrap_split_rows_vertical in Views Bootstrap 7.3
Distribute items in columns as required for vertical alignment.
Parameters
array $rows: The rendered views result rows.
int $nb_columns: The desired number of columns per row.
Return value
array A multi-dimensional array with the calculated columns.
1 call to _views_bootstrap_split_rows_vertical()
- _views_bootstrap_preprocess_views_style_plugin_prepare_grid_vertical in ./
views_bootstrap.module - Further preprocessing for vertical alignment.
File
- ./
views_bootstrap.module, line 62 - Bootstrap integration.
Code
function _views_bootstrap_split_rows_vertical(array $rows, $nb_columns) {
$col = 0;
$row = 0;
$items = array();
$remainders = count($rows) % $nb_columns;
$num_rows = floor(count($rows) / $nb_columns);
// Iterate over each rendered views result row.
foreach ($rows as $item) {
// Add the item.
$items[$col]['content'][$row]['content'] = $item;
// Increase, decrease or reset appropriate integers.
$row++;
if (!$remainders && $row == $num_rows) {
$row = 0;
$col++;
}
elseif ($remainders && $row == $num_rows + 1) {
$row = 0;
$col++;
$remainders--;
}
}
return $items;
}