【发布时间】:2018-07-24 19:43:34
【问题描述】:
<?php
function customtable_permission() {
return array(
'show people' => array(
'title' => t('List of people'),
'description' => t('The table'),
),
);
}
function customtable_menu() {
$items = array();
$items['people'] = array(
'type' => MENU_NORMAL_ITEM,
'title' => t('Title'),
'description' => 'This page should show a table from a remote DB',
'page callback' => 'customtable_db_data',
'access arguments' => array('show people'),
);
return $items;
}
function customtable_db_data() {
db_set_active('remote_database');
$results = db_query("SELECT * FROM {people}");
$header = array(t('Id'), t('Name'), t('Department'), t('Division'), t('Insurance'));
$rows = array();
foreach($results AS $result) {
$rows[] = array(
$result->id,
$result->name,
$result->department,
$result->division,
$result->insurance,
);
}
db_set_active('default');
return theme('table', array('header'=> $header, 'rows' => $rows));
}
?>
这一切都很好,我可以访问 site.com/people 并查看数据库中的所有条目都打印在表格中
但我想要可以过滤每一列的文本框。用户可以按名称或特定的保险或部门进行搜索。我认为以编程方式是可能的,但我想知道是否有更“drupal”的方法。内容类型能够过滤其字段。我是否要根据我的查询创建内容类型?我不完全知道。任何帮助表示赞赏。
【问题讨论】: