views-view-table.tpl.php

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

views-view-table.tpl.php Template to display a view as a table.

  • $title : The title of this group of rows. May be empty.
  • $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.
  • $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.

File

theme/views-view-table.tpl.php
View source
  1. <?php
  2. /**
  3. * @file views-view-table.tpl.php
  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. * - $fields: An array of CSS IDs to use for each field id.
  9. * - $class: A class or classes to apply to the table, based on settings.
  10. * - $row_classes: An array of classes to apply to each row, indexed by row
  11. * number. This matches the index in $rows.
  12. * - $rows: An array of row items. Each row is an array of content.
  13. * $rows are keyed by row number, fields within rows are keyed by field ID.
  14. * @ingroup views_templates
  15. */
  16. ?>
  17. <table class="<?php print $class; ?>"<?php print $attributes; ?>>
  18. <?php if (!empty($title)) : ?>
  19. <caption><?php print $title; ?></caption>
  20. <?php endif; ?>
  21. <thead>
  22. <tr>
  23. <?php foreach ($header as $field => $label): ?>
  24. <th class="views-field views-field-<?php print $fields[$field]; ?>">
  25. <?php print $label; ?>
  26. </th>
  27. <?php endforeach; ?>
  28. </tr>
  29. </thead>
  30. <tbody>
  31. <?php foreach ($rows as $count => $row): ?>
  32. <tr class="<?php print implode(' ', $row_classes[$count]); ?>">
  33. <?php foreach ($row as $field => $content): ?>
  34. <td class="views-field views-field-<?php print $fields[$field]; ?>">
  35. <?php print $content; ?>
  36. </td>
  37. <?php endforeach; ?>
  38. </tr>
  39. <?php endforeach; ?>
  40. </tbody>
  41. </table>

Related topics