根据变量突出显示 table 行

Highlight table row depending on variable

我有一个自定义 drupal 模块,我正在使用主题 'table' 创建一个 table。

$header = array();
$header[] = array("data" => "Home Team");
$header[] = array("data" => "Away Team");

$row = array();

foreach ($node as $game) {
  $row = [$hometeam), $awayteam)];
  $rows[] = $row;
}

$table = theme('table', array('header' => $header, 'rows' => $rows));

return $table;

我也在我的站点中使用 Bootstrap 主题。 我想突出显示某些变量满足要求的所有行。例如,突出显示 'Home Team' == 'something'.

的所有行

在我看来,我无法覆盖主题 类 还是我遗漏了什么?

如果像 header 那样构建行,则可以为行或单元格设置属性。 theme_table 文档中有一个向行添加 class 的示例。

$rows = array(
  // Simple row
  array(
    'Cell 1', 'Cell 2', 'Cell 3'
  ),
  // Row with attributes on the row and some of its cells.
  array(
    'data' => array(
      'Cell 1', 
      array('data' => 'Cell 2', 'colspan' => 2)
    ), 
    'class' => array('funky') // <-- row class
  )
);