【问题标题】:theme_table drupal development主题表drupal开发
【发布时间】:2011-07-26 18:46:33
【问题描述】:

更新

我已经制作了这张表:我有 2 个数组的 UGentArray 和 InternshipsArray。我怎样才能在我的桌子上设置这些?而不是“第 1 行数据”和“第 2 行数据”。我的问题是:我希望 UgentArray 和 InternshipArray 中的值作为每个标题 UGentID 和 Internships 下的 2 列

enter code here// Make table and display on screen.
$tbl_header = array();
$tbl_header[] = array("data" => "UGentID");
$tbl_header[] = array("data" => "Internships");
$tbl_row = array();    
foreach($studentUGentID as $key => $value) {
    for($i = 0; $i<count($value); $i++) {
        $tbl_row[] = $value[$i]['value'];
    }
}
$tbl_row[] = "Row column 2 data";
$tbl_rows = array();
$tbl_rows[] = $tbl_row;    
$html = theme_table($tbl_header,$tbl_rows);
return $html;![enter image description here][1]

【问题讨论】:

  • 不是答案,而是一般性评论。与其调用theme_table,不如调用theme('table', ...。 IE。 theme('table', $tbl_header, $tbl_rows) 在上面的示例中。
  • 确实输出,现在看起来好多了。我遵循了这个例子:chooch.net/user/21/drupal-themetable-example。无论如何,感谢您的帮助!
  • 如果你愿意,我可以迁移到 drupal.SE;你可能会在那里获得更多的点击率。
  • 是的,请。谢谢你的帮助,威尔!

标签: php drupal drupal-6 drupal-modules drupal-7


【解决方案1】:

如果没有您开始使用的数据示例,很难为您提供准确的代码来解决您的问题。

一般来说,在 Drupal 中构建表格的最佳方式是这样的:


$table_headers = array(
  t('UGentID'), // this is the header for the first column
  t('Internships'), // this is the header for the second column
);
$table_rows = array()
foreach ($studentUGentID as $key => $value) {
  $table_rows[] = array(
    'column 1 data', // add all the data for the row one column
    'column 2 data', // at a time
  );
}
$html = theme('table', $table_headers, $table_rows);

正如我在不知道 $studentUGentID$internships 中的内容的情况下所说的那样,我无能为力。

通过示例数据,我可以为您提供更多帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    相关资源
    最近更新 更多