You are here

function _views_bootstrap_split_rows_horizontal in Views Bootstrap 7.3

Distribute items in rows/columns as required for horizontal 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 rows and columns.

1 call to _views_bootstrap_split_rows_horizontal()
_views_bootstrap_preprocess_views_style_plugin_prepare_grid_horizontal in ./views_bootstrap.module
Further preprocessing for horizontal alignment.

File

./views_bootstrap.module, line 26
Bootstrap integration.

Code

function _views_bootstrap_split_rows_horizontal(array $rows, $nb_columns) {
  $col = 0;
  $row = 0;
  $items = array();

  // Iterate over each rendered views result row.
  foreach ($rows as $item) {

    // Add the item.
    $items[$row]['content'][$col]['content'] = $item;

    // If we've reached the maximum number of columns per row, reset the column
    // index and proceed to the next row.
    if ($col == $nb_columns - 1) {
      $col = 0;
      $row++;
    }
    else {
      $col++;
    }
  }
  return $items;
}