How to get multiple parameters sent via drupal hook_menu

Vikas Naranje picture Vikas Naranje · Sep 13, 2011 · Viewed 9.7k times · Source

I've got this menu hook below by which I'm sending two parameters to the function.

But in the function I am only receiving the first parameter.

Does any one know how to send and get multiple parameters using the Drupal menu system?

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));
}

Answer

Clive picture Clive · Sep 13, 2011

You're already doing it exactly the right way, if it's not working try flushing your caches. It's possible they haven't been cleared since you added the second argument, and Drupal caches items return from hook_menu() so it doesn't have to be called on each page.