简体   繁体   English

theme_table drupal开发

[英]theme_table drupal development

update 更新

I have made this table: I have 2 array's UGentArray and InternshipsArray. 我做了这张表:我有2个数组的UGentArray和InternshipsArray。 How can I set these in my table? 如何在表格中设置这些内容? instead of "Row column 1 data" and "Row column 2 data". 而不是“第1列数据”和“第2列数据”。 My question is: I want the values from UgentArray and InternshipArray as 2 columns under Each title UGentID and Internships 我的问题是:我希望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]

在此处输入图片说明

Without having an example of the data you are starting with it is difficult to give you exact code to solve your problem. 如果没有示例数据,那么很难为您提供准确的代码来解决问题。

In general the best way to built tables in Drupal is like this: 通常,在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);

As I said without knowing what is in $studentUGentID and $internships I cannot help further. 正如我所说的那样,我不知道$studentUGentID$internships什么。

With sample data I could help you more. 借助示例数据,我可以为您提供更多帮助。

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

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