繁体   English   中英

theme_table drupal开发

[英]theme_table drupal development

更新

我做了这张表:我有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]

在此处输入图片说明

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

通常,在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什么。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM