如何通过drupal hook_menu发送多个参数

Vik*_*nje 7 php drupal drupal-6 drupal-7

我在下面有这个菜单挂钩,我正在向函数发送两个参数.

但在函数中我只收到第一个参数.

有没有人知道如何使用Drupal菜单系统发送和获取多个参数?

function drupal_menu(){
    $items = array();
    $items['drupal/%/%'] = array(
        'title' => t('Welcome to the Hello World Module'),
        'page callback' => 'drupal_page',
        'page arguments' => array(1,2),
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}


function drupal_page($arg1, $arg2) {    
    return drupal_json(array('mess1'=>$arg1,'mess2'=>$arg2));
}
Run Code Online (Sandbox Code Playgroud)

Cli*_*ive 8

你已经完全以正确的方式做到了,如果它不起作用,请尝试刷新你的缓存.由于您添加了第二个参数,因此它们可能尚未被清除,而Drupal缓存了从hook_menu()返回的项目,因此不必在每个页面上调用它.