views-view-table.tpl.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Template to display a view as a table.
  5. *
  6. * - $title : The title of this group of rows. May be empty.
  7. * - $header: An array of header labels keyed by field id.
  8. * - $caption: The caption for this table. May be empty.
  9. * - $header_classes: An array of header classes keyed by field id.
  10. * - $fields: An array of CSS IDs to use for each field id.
  11. * - $classes: A class or classes to apply to the table, based on settings.
  12. * - $row_classes: An array of classes to apply to each row, indexed by row
  13. * number. This matches the index in $rows.
  14. * - $rows: An array of row items. Each row is an array of content.
  15. * $rows are keyed by row number, fields within rows are keyed by field ID.
  16. * - $field_classes: An array of classes to apply to each field, indexed by
  17. * field id, then row number. This matches the index in $rows.
  18. *
  19. * @ingroup views_templates
  20. */
  21. ?>
  22. <table <?php if ($classes): ?> class="<?php print $classes; ?>"<?php endif ?><?php print $attributes; ?>>
  23. <?php if (!empty($title) || !empty($caption)): ?>
  24. <caption><?php print $caption . $title; ?></caption>
  25. <?php endif; ?>
  26. <?php if (!empty($header)) : ?>
  27. <thead>
  28. <tr>
  29. <?php foreach ($header as $field => $label): ?>
  30. <th <?php if ($header_classes[$field]): ?> class="<?php print $header_classes[$field]; ?>"<?php endif; ?> scope="col">
  31. <?php print $label; ?>
  32. </th>
  33. <?php endforeach; ?>
  34. </tr>
  35. </thead>
  36. <?php endif; ?>
  37. <tbody>
  38. <?php foreach ($rows as $row_count => $row): ?>
  39. <tr <?php if ($row_classes[$row_count]): ?> class="<?php print implode(' ', $row_classes[$row_count]); ?>"<?php endif; ?>>
  40. <?php foreach ($row as $field => $content): ?>
  41. <td <?php if ($field_classes[$field][$row_count]): ?> class="<?php print $field_classes[$field][$row_count]; ?>"<?php endif; ?><?php print drupal_attributes($field_attributes[$field][$row_count]); ?>>
  42. <?php print $content; ?>
  43. </td>
  44. <?php endforeach; ?>
  45. </tr>
  46. <?php endforeach; ?>
  47. </tbody>
  48. </table>