Hello team Viewsm thank you so much for the module ... indispensable!!

I searched but did not find a thread covering this error.

I get error warning: Division by zero in /home/glambook/public_html/sites/all/modules/views/theme/theme.inc on line 400.

Line 400 read "if (($count + 1) % $columns == 0) {" (prefunction section below ...)
Displayed on screen, home page.
The more content changes, the more lines get displayed.
Using Acquia Marina, but I get it when switching to Garland as well.
I uninstalled and reinstalled Views but the error is still there

I am new to Drupal, not a coder. I have many views enabled, is there a way to find out which one might be causing the error ... if one of them is the cause?

Anybody knows a fix?

Fonction starts at line 384 for me
function template_preprocess_views_view_grid(&$vars) {
$view = $vars['view'];
$result = $view->result;
$options = $view->style_plugin->options;
$handler = $view->style_plugin;

$columns = $options['columns'];

$rows = array();

if ($options['alignment'] == 'horizontal') {
$row = array();
$row_count = 0;
foreach ($vars['rows'] as $count => $item) {
$row[] = $item;
$row_count++;
if (($count + 1) % $columns == 0) {
$rows[] = $row;
$row = array();
$row_count = 0;
}
}
if ($row) {
// Fill up the last line.
for ($i = 0; $i < ($columns - $row_count); $i++) {
$row[] = '';
}
$rows[] = $row;
}
}
else {
$num_rows = floor(count($vars['rows']) / $columns);
// The remainders are the 'odd' columns that are slightly longer.
$remainders = count($vars['rows']) % $columns;
$row = 0;
$col = 0;
foreach ($vars['rows'] as $count => $item) {
$rows[$row][$col] = $item;
$row++;

if (!$remainders && $row == $num_rows) {
$row = 0;
$col++;
}
else if ($remainders && $row == $num_rows + 1) {
$row = 0;
$col++;
$remainders--;
}
}
for ($i = 0; $i < count($rows[0]); $i++) {
// This should be string so that's okay :)
if (!isset($rows[count($rows) - 1][$i])) {
$rows[count($rows) - 1][$i] = '';
}
}
}
$vars['rows'] = $rows;
}

Comments

arnaudfischer’s picture

Status: Active » Closed (fixed)

Well, I identified the views causing the issue, a grid block. I changed the format to HTML list to get ridd of the error. Closing, but I think there might still be an issue.

-arnaud

mattcasey’s picture

I had the same problem recently with a View using Grid style. After switching to HTML List it removed the problem, and even after switching back to Grid, the problem did not return.

- matt