views_bonus_grid.module

Tracking 5.x-1.x branch
  1. drupal
    1. 5 contributions/views_bonus/views_bonus_grid.module

Functions & methods

NameDescription
theme_views_bonus_view_grid
views_bonus_grid_views_style_plugins

File

View source
  1. <?php
  2. function views_bonus_grid_views_style_plugins() {
  3. $items['bonus_grid'] = array(
  4. 'name' => t('Bonus: Grid View'),
  5. 'theme' => 'views_bonus_view_grid',
  6. 'validate' => 'views_ui_plugin_validate_list',
  7. 'needs_fields' => true,
  8. );
  9. return $items;
  10. }
  11. function theme_views_bonus_view_grid($view, $nodes, $type) {
  12. drupal_add_css(drupal_get_path('module', 'views_bonus_grid') .'/views_bonus.css');
  13. $fields = _views_get_fields();
  14. $content = '';
  15. // set default count.
  16. $cols = $view->gridcount ? $view->gridcount : 4;
  17. $count = 0;
  18. $row_count = 0;
  19. $total = count($nodes);
  20. foreach ($nodes as $node) {
  21. $item = '';
  22. if ($count % $cols == 0) {
  23. $stripe = ++$row_count % 2 ? 'odd' : 'even';
  24. $content .= '<tr class="' . $stripe . '">';
  25. }
  26. foreach ($view->field as $field) {
  27. if ($fields[$field['id']]['visible'] !== FALSE) {
  28. if ($field['label']) {
  29. $item .= "<div class='view-label view-label-$field[queryname]'>" . $field['label'] . "</div>";
  30. }
  31. $item .= "<div class='view-field view-data-$field[queryname]'>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "</div>";
  32. }
  33. }
  34. $content .= "<td class='view-grid-item'><div class='view-item view-item-$view->name'>$item</div></td>\n";
  35. $count++;
  36. if ($count % $cols == 0 || $count == $total) {
  37. $content .= '</tr>';
  38. }
  39. }
  40. if ($content) {
  41. return '<table class="view-grid view-grid-' . $view->name . '">' .
  42. $content .
  43. '</table>';
  44. }
  45. }