use*_*001 5 php drupal drupal-views drupal-6 drupal-modules
我用一个简单的菜单结构制作了一个模块.我能够以编程方式检索PHP中所有学生的视图.现在,我想在一个简单的表格中返回页面上的所有学生.
表的结构是
UGhentID姓名学生名字学生位置学生
12874749史密斯尼克纽约...
Haz*_*aza 16
如果要创建新页面,则需要在模块中使用hook_menu.
举个例子 :
/**
* Implementation of hook_menu.
*/
function mymodule_menu() {
$items = array();
$items['myPage'] = array(
'title' => 'Finances',
'page callback' => 'mymodule_page',
'access callback' => 'user_access',
'access argument' => array('access nodes'),
);
return $items
}
/**
* Page callback
*/
function mymodule_page() {
$output = mymodule_table();
return $output;
}
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到我在页面回调中调用"mymodule_table()",这是你构建表的地方.
function mymodule_table() {
$rows = array();
// build the table header
$header = array();
for ($i = 1; $i <= 5; $i++) {
$header[] = array('data' => $i, 'class' => 'header-class');
}
$row = array();
for ($i = 1; $i <= 5; $i++) {
$row[] = array('data' => $i, 'class' => 'row-class');
}
$rows[] = array('data' => $row);
$output .= theme('table', $header, $rows, $attributes = array('class' => 'my-table-class'));
return $output;
}
Run Code Online (Sandbox Code Playgroud)
这应该输出一个表,标题是一行一行,有5列.
归档时间: |
|
查看次数: |
10034 次 |
最近记录: |