t('Bonus: Grid View'), 'theme' => 'views_bonus_view_grid', 'validate' => 'views_ui_plugin_validate_list', 'needs_fields' => true, ); return $items; } function theme_views_bonus_view_grid($view, $nodes, $type) { drupal_add_css(drupal_get_path('module', 'views_bonus_grid') .'/views_bonus.css'); $fields = _views_get_fields(); $content = ''; // set default count. $cols = $view->gridcount ? $view->gridcount : 4; $count = 0; $row_count = 0; $total = count($nodes); foreach ($nodes as $node) { $item = ''; if ($count % $cols == 0) { $stripe = ++$row_count % 2 ? 'odd' : 'even'; $content .= ''; } foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { if ($field['label']) { $item .= "
" . $field['label'] . "
"; } $item .= "
" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "
"; } } $content .= "
$item
\n"; $count++; if ($count % $cols == 0 || $count == $total) { $content .= ''; } } if ($content) { return '' . $content . '
'; } }