diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b7f662e3801329b60922b618fa390088b5a3be3f..ab7e6ca15daaf70912ff0f75bf44fa67160194d5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -99,4 +99,5 @@ Views 2.3 o #343047 by alienbrain: Allow all handlers to participate in view validation. o #339223 by greggles: Allow taxonomy term tid to be sortable. o #324378 by eigentor: CSS improvements to the view list page. - o #354736 by Shai: Clarification on exposed filter text. \ No newline at end of file + o #354736 by Shai: Clarification on exposed filter text. + o #364637 by moshe and dww: Allow preprocessors to add row classes to table style. \ No newline at end of file diff --git a/theme/theme.inc b/theme/theme.inc index ec7134f77fb582876c2d1a018904682c5d1c0282..b9b0f5e563a9482c5ed117dc0191250dab397547 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -353,6 +353,10 @@ function template_preprocess_views_view_table(&$vars) { } } + foreach ($vars['rows'] as $num => $row) { + $vars['row_classes'][$num][] = ($num % 2 == 0) ? 'odd' : 'even'; + } + $vars['class'] = 'views-table'; if (!empty($options['sticky'])) { drupal_add_js('misc/tableheader.js'); diff --git a/theme/views-view-table.tpl.php b/theme/views-view-table.tpl.php index c8440e64cdaeac594a91ecc86312d99c98dc2ce4..8a622b789eeceb18d801e4df5ce664d18f2b4948 100644 --- a/theme/views-view-table.tpl.php +++ b/theme/views-view-table.tpl.php @@ -8,8 +8,10 @@ * - $header: An array of header labels keyed by field id. * - $fields: An array of CSS IDs to use for each field id. * - $class: A class or classes to apply to the table, based on settings. - * - $rows: An array of row items. Each row is an array of content - * keyed by field ID. + * - $row_classes: An array of classes to apply to each row, indexed by row + * number. This matches the index in $rows. + * - $rows: An array of row items. Each row is an array of content. + * $rows are keyed by row number, fields within rows are keyed by field ID. * @ingroup views_templates */ ?> @@ -28,7 +30,7 @@ $row): ?> - + $content): ?>