문제

I know how to pass one argument to a menu callback

  $items['someaddress/%'] = array(
    'title' => 'title',
    'page callback' => 'some_function',
    'page arguments' => 1,
    'type' => MENU_CALLBACK
  );

I don't understand why the argument being passed is $_POST['nid'] but this works. It corresponds to page argument 1.

function some_function (){

    $node = isset($_POST['nid']) ? node_load($_POST['nid']) : FALSE;

}

I'm now trying to pass multiple arguments. $items['someaddress/%/%/%'] = array( and is looking for a code sample of how I do that.

Thanks!

도움이 되었습니까?

해결책

Use an array for 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
}

You should always keep arguments passed to menu callbacks as an array, anyway.

FYI: the behavior you are seeing is how Drupal's menu system is designed. The number corresponds to each argument being passed to the menu. 1 is the first argument, 2 is the second, etc.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top