Mar*_*ark 0 drupal drupal-6 drupal-routes
我知道如何将一个参数传递给菜单回调
$items['someaddress/%'] = array(
'title' => 'title',
'page callback' => 'some_function',
'page arguments' => 1,
'type' => MENU_CALLBACK
);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么传递的论点是$_POST['nid']有效的.它对应于页面参数1.
function some_function (){
$node = isset($_POST['nid']) ? node_load($_POST['nid']) : FALSE;
}
Run Code Online (Sandbox Code Playgroud)
我现在正试图传递多个参数. $items['someaddress/%/%/%'] = array(并正在寻找我如何做的代码示例.
谢谢!
小智 12
使用数组page arguments:
$items['someaddress/%/%/%'] = array(
'title' => 'title',
'page callback' => 'some_function',
'page arguments' => array(1, 2, 3),
'type' => MENU_CALLBACK,
);
function some_function($arg1, $arg2, $arg3) {
// Insert code here
}
Run Code Online (Sandbox Code Playgroud)
无论如何,您应始终将参数传递给菜单回调作为数组.
仅供参考:你看到的行为是Drupal菜单系统的设计方式.该数字对应于传递给菜单的每个参数.1是第一个参数,2是第二个,等等.
| 归档时间: |
|
| 查看次数: |
7283 次 |
| 最近记录: |