You are here

views-view-pivot-table.tpl.php in Pivot Tables for Views 7

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.
  • $header_classes: An array of header classes keyed by field id.
  • $header_attributes: An array of header attributes keyed by field id.
  • $fields: An array of CSS IDs to use for each field id.
  • $classes: 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.
  • $field_classes: An array of classes to apply to each field, indexed by field id, then row number. This matches the index in $rows.

File

views-view-pivot-table.tpl.php
View source
<?php

/**
 * @file
 * 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.
 * - $header_classes: An array of header classes keyed by field id.
 * - $header_attributes: An array of header attributes keyed by field id.
 * - $fields: An array of CSS IDs to use for each field id.
 * - $classes: 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.
 * - $field_classes: An array of classes to apply to each field, indexed by
 *   field id, then row number. This matches the index in $rows.
 * @ingroup views_templates
 */
?>
<table <?php

if ($classes) {
  print 'class="' . $classes . '" ';
}
print $attributes;
?>>
  <?php

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

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

}
?>
  <?php

if (!empty($header)) {
  ?>
    <thead>
    <tr>
      <?php

  foreach ($pivot_rows as $field => $label) {
    ?>
        <th <?php

    if (!empty($header_classes[$field])) {
      print 'class="' . $header_classes[$field] . '" ';
    }
    if (!empty($header_attributes[$field])) {
      print drupal_attributes($header_attributes[$field]);
    }
    ?>>
          <?php

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

  }
  ?>
      <?php

  foreach ($header as $field => $label) {
    ?>
        <th <?php

    if (!empty($header_classes[$field])) {
      print 'class="' . $header_classes[$field] . '" ';
    }
    if (!empty($header_attributes[$field])) {
      print drupal_attributes($header_attributes[$field]);
    }
    ?>>
          <?php

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

  }
  ?>
    </tr>
    <?php

  if (!$hide_subheader) {
    ?>
      <?php

    if ($vertical) {
      ?>
        <?php

      foreach ($subheader as $field => $label) {
        ?>
          <tr>
            <?php

        foreach ($header as $headerfield => $headerlabel) {
          ?>
              <th <?php

          if (!empty($header_classes[$field])) {
            print 'class="' . $header_classes[$field] . '" ';
          }
          if (!empty($header_attributes[$field])) {
            print drupal_attributes($header_attributes[$field]);
          }
          ?>>
                <?php

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

        }
        ?>
          </tr>
        <?php

      }
      ?>
      <?php

    }
    else {
      ?>
        <tr>
          <?php

      foreach ($header as $field => $label) {
        ?>
            <?php

        foreach ($subheader as $field => $label) {
          ?>
              <th <?php

          if (!empty($header_classes[$field])) {
            print 'class="' . $header_classes[$field] . '" ';
          }
          if (!empty($header_attributes[$field])) {
            print drupal_attributes($header_attributes[$field]);
          }
          ?>>
                <?php

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

        }
        ?>
          <?php

      }
      ?>
        </tr>
      <?php

    }
    ?>
    <?php

  }
  ?>
    </thead>
  <?php

}
?>
  <tbody>
  <?php

foreach ($rows as $row_key => $row) {
  ?>
  <tr <?php

  if (!empty($row_classes[$row_key])) {
    print 'class="' . implode(' ', $row_classes[$row_key]) . '"';
  }
  ?>>
    <?php

  foreach ($pivot_rows as $hkey => $label) {
    ?>
      <td <?php

    if (!empty($row_attributes[$row_key])) {
      print drupal_attributes($row_attributes[$row_key]);
    }
    ?>>
        <?php

    print empty($row[$hkey]) ? '' : $row[$hkey];
    ?>
      </td>
    <?php

  }
  ?>
    <?php

  if ($vertical) {
    ?>
      <?php

    foreach ($subheader as $shkey => $label) {
      ?>
        <?php

      foreach ($header as $hkey => $label) {
        ?>
          <?php

        $key = $shkey . ':' . $hkey;
        ?>
          <td <?php

        if (!empty($field_classes[$shkey][$row_key])) {
          print 'class="' . $field_classes[$shkey][$row_key] . '" ';
        }
        if (!empty($field_attributes[$shkey][$row_key])) {
          print drupal_attributes($field_attributes[$shkey][$row_key]);
        }
        ?>>
            <?php

        print empty($row[$key]) ? '' : $row[$key];
        ?>
          </td>
        <?php

      }
      ?>
        </tr><tr>
      <?php

    }
    ?>
    <?php

  }
  else {
    ?>
      <?php

    foreach ($header as $hkey => $label) {
      ?>
        <?php

      if (!empty($aggregate_columns[$hkey])) {
        ?>
          <td><?php

        print empty($row[$hkey]) ? '' : $row[$hkey];
        ?></td>
        <?php

      }
      else {
        ?>
          <?php

        foreach ($subheader as $shkey => $label) {
          ?>
            <?php

          $key = $shkey . ':' . $hkey;
          ?>
            <td <?php

          if (!empty($field_classes[$shkey][$row_key])) {
            print 'class="' . $field_classes[$shkey][$row_key] . '" ';
          }
          if (!empty($field_attributes[$shkey][$row_key])) {
            print drupal_attributes($field_attributes[$shkey][$row_key]);
          }
          ?>>
              <?php

          print empty($row[$key]) ? '' : $row[$key];
          ?>
            </td>
          <?php

        }
        ?>
        <?php

      }
      ?>
      <?php

    }
    ?>
    <?php

  }
  ?>
    </tr>
  <?php

}
?>
  </tbody>
</table>