저는 드루팔 (Drupal 7)에 모듈을 작성하고 있습니다. 콘텐츠 관리에서 테이블과 같은 테이블을 만들고 싶습니다. 이렇게 정렬 된 표를 만들 수 있지만 헤더와 각 행에 확인란을 어떻게 추가 할 수 있습니까? 문제는 테이블 형태처럼 초기화 할 수 있어야합니다,drupal 7의 정렬 된 테이블에 확인란을 추가하는 방법은 무엇입니까?
$header = array(
array('data' => 'Title', 'field' => 'title'),
array('data' => 'Created', 'field' => 'created','sort' => 'desc'),
array('data' => 'Published', 'field' => 'status'),
array('data' => 'Action'),
);
$result = db_select('news','n')->extend('PagerDefault')
->fields('n')
->limit(10) //This is we can change the number of rows
->extend('TableSort') // Sorting Extender
->orderByHeader($header)// Field to sort on is picked from $header
->execute()->fetchAll();
$path = drupal_get_path("module","tuan_nguyen");
foreach($result as $row){
$img = $path."/del.png";
if($row->status == 1){
$img = $path."/check.png";
}
$date = format_date($row->created,'medium','','Asia/Ho_Chi_Minh');
$rows[$row->id] = array(
l($row->title,'admin/tuan_nguyen/news/edit/'.$row->id),
$date,
"<img width='30px' height='30px' src='".$img."'/>",
l('Edit','admin/tuan_nguyen/news/edit/'.$row->id).'/'.l('Del','admin/tuan_nguyen/news/del/'.$row->id),
);
}
//Create a render array ($build) which will be themed as a table with a pager
$build['tuan_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' =>t('Table is empty'),
);
//attach the pager theme
$build['tuan_pager'] = array('#theme' => 'pager');
return $build;