theme_table drupal development - PullRequest
       40

theme_table drupal development

0 голосов
/ 31 марта 2011

обновление

Я сделал эту таблицу: у меня есть 2 массива UGentArray и InternshipsArray.Как я могу установить их в моей таблице?вместо «Данные столбца строки 1» и «Данные столбца строки 2».Мой вопрос: я хочу, чтобы значения из UgentArray и InternshipArray представляли собой 2 столбца под каждым заголовком UGentID и Internships

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]

enter image description here

1 Ответ

1 голос
/ 01 апреля 2011

Без примера данных, с которых вы начинаете, трудно дать вам точный код для решения вашей проблемы.

В общем, лучший способ построения таблиц в 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, я не могу помочь дальше.

С примерами данных я мог бы помочь вам больше.

...