You are here

datatables-view.tpl.php in DataTables 6

Same filename and directory in other branches
  1. 7.2 views/datatables-view.tpl.php
  2. 7 views/datatables-view.tpl.php

Template to display a datatable.

  • $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

views/datatables-view.tpl.php
View source
<?php

/**
 * @file
 * Template to display a datatable.
 *
 * - $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.
 */
?>
<table id="<?php

print $id;
?>" class="<?php

print $class;
?>">
  <?php

if (!empty($title)) {
  ?>
    <caption><?php

  print $title;
  ?></caption>
  <?php

}
?>
  <thead>
    <tr>
      <?php

foreach ($header as $field => $label) {
  ?>
        <th class="views-field views-field-<?php

  print $fields[$field];
  ?>">
          <?php

  print $label;
  ?>
        </th>
      <?php

}
?>
    </tr>
  </thead>
  <tbody>
    <?php

foreach ($rows as $count => $row) {
  ?>
      <tr class="<?php

  print implode(' ', $row_classes[$count]);
  ?>">
        <?php

  foreach ($row as $field => $content) {
    ?>
          <td class="views-field views-field-<?php

    print $fields[$field];
    ?>">
            <?php

    print $content;
    ?>
          </td>
        <?php

  }
  ?>
      </tr>
    <?php

}
?>
  </tbody>
</table>