views-view-grid.tpl.php

  1. 3.x theme/views-view-grid.tpl.php
  2. 2.x theme/views-view-grid.tpl.php

views-view-grid.tpl.php Default simple view template to display a rows in a grid.

  • $rows contains a nested array of rows. Each row contains an array of columns.
  • $class contains the class of the table.
  • $attributes contains other attributes for the table.

File

theme/views-view-grid.tpl.php
View source
  1. <?php
  2. /**
  3. * @file views-view-grid.tpl.php
  4. * Default simple view template to display a rows in a grid.
  5. *
  6. * - $rows contains a nested array of rows. Each row contains an array of
  7. * columns.
  8. * - $class contains the class of the table.
  9. * - $attributes contains other attributes for the table.
  10. * @ingroup views_templates
  11. */
  12. ?>
  13. <?php if (!empty($title)) : ?>
  14. <h3><?php print $title; ?></h3>
  15. <?php endif; ?>
  16. <table class="<?php print $class; ?>"<?php print $attributes; ?>>
  17. <tbody>
  18. <?php foreach ($rows as $row_number => $columns): ?>
  19. <?php
  20. $row_class = 'row-' . ($row_number + 1);
  21. if ($row_number == 0) {
  22. $row_class .= ' row-first';
  23. }
  24. if (count($rows) == ($row_number + 1)) {
  25. $row_class .= ' row-last';
  26. }
  27. ?>
  28. <tr class="<?php print $row_class; ?>">
  29. <?php foreach ($columns as $column_number => $item): ?>
  30. <td class="<?php print $column_classes[$row_number][$column_number]; ?>">
  31. <?php print $item; ?>
  32. </td>
  33. <?php endforeach; ?>
  34. </tr>
  35. <?php endforeach; ?>
  36. </tbody>
  37. </table>

Related topics