簡體   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