You are here

function theme_matrix_table in Matrix field 6.2

Same name and namespace in other branches
  1. 8.2 matrix.module \theme_matrix_table()
  2. 7.2 matrix.module \theme_matrix_table()

Themes a matrix table This is similar to theme_table except it prepends the $first_col to each $rows @param$header An array containing the table headers. @param$first_col An array containing the left hand side headers.

Parameters

$rows An array of table rows. Every row is an array of cells.:

$attributes An array of HTML attributes to apply to the table tag.:

$caption A localized string to use for the <caption> tag.:

Return value

HTML

3 theme calls to theme_matrix_table()
content-field-field_fieldname.tpl.php in ./content-field-field_fieldname.tpl.php
content-field.tpl.php Default theme implementation to display the value of a field.
matrix_handler_field::render in ./matrix_handler_field.inc
theme_matrix_formatter_default in ./matrix.module
Theme function for 'default' text field formatter.

File

./matrix.module, line 921
Defines simple matrix field types.

Code

function theme_matrix_table($data, $attributes = array(), $caption = NULL) {
  if (is_array($data)) {
    $header = array_shift($data);
    $attributes['class'] .= " matrix-table";

    // Identify Last Column
    foreach ($data as $row_id => $row) {
      foreach ($row as $col_id => $cell) {
      }
      if (is_array($data[$row_id][$col_id])) {
        $data[$row_id][$col_id]['class'] = 'matrix-last-col';
      }
      else {
        $data[$row_id][$col_id] = array(
          'class' => 'matrix-last-col',
          'data' => $data[$row_id][$col_id],
        );
      }
    }
    if (is_array($header[$col_id])) {
      $header[$col_id]['class'] = 'matrix-last-col';
    }
    else {
      $header[$col_id] = array(
        'class' => 'matrix-last-col',
        'data' => $header[$col_id],
      );
    }

    // Identify Last Row
    $data[$row_id] = array(
      'data' => $data[$row_id],
      'class' => 'matrix-last-row',
    );
    return theme('table', $header, $data, $attributes, $caption);
  }
  else {
    return "";
  }
}