主题表drupal开发 [英] theme_table drupal development

查看:21
本文介绍了主题表drupal开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have made this table: I have 2 array's UGentArray and InternshipsArray. How can I set these in my table? instead of "Row column 1 data" and "Row column 2 data". My question is: I want the values from UgentArray and InternshipArray as 2 columns under Each title UGentID and 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]

推荐答案

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

Without having an example of the data you are starting with it is difficult to give you exact code to solve your problem.

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

In general the best way to built tables in Drupal is like this:


$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 中的内容的情况下所说的那样,我无能为力.

As I said without knowing what is in $studentUGentID and $internships I cannot help further.

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

With sample data I could help you more.

这篇关于主题表drupal开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆