Skip to content

Instantly share code, notes, and snippets.

@gagarine
Created August 17, 2011 20:01
Show Gist options
  • Save gagarine/1152457 to your computer and use it in GitHub Desktop.
Save gagarine/1152457 to your computer and use it in GitHub Desktop.
views theme.inc arround line 500
<?php
function template_preprocess_views_view_unformatted(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
$vars['classes'] = array();
// Set up striping values.
foreach ($rows as $id => $row) {
$row_classes = array();
$row_classes[] = 'views-row';
$row_classes[] = 'views-row-' . ($id + 1);
$row_classes[] = 'views-row-' . ($id % 2 ? 'even' : 'odd');
if ($id == 0) {
$row_classes[] = 'views-row-first';
}
if ($id == count($rows) -1) {
$row_classes[] = 'views-row-last';
}
// Flatten the classes to a string for each row for the template file.
$vars['classes'][$id] = implode(' ', $row_classes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment