Search code examples
drupaldrupal-6drupal-routes

passing integers as parameter in drupal menu


I'm using drupal 6

Suppose I have

  $items['path/yo'] = array(
    'page callback' => 'callback_function',
    'page arguments' => array(1),
    'type' => MENU_CALLBACK,
  );

It will instead pass in the part of the path that is in the 1-th position (in this case it will pass 'yo') into the callback_function function...

But what if I'm actually TRYING to pass in the integer 1 into the function? How would I do that without casting it as string first and then reconverting to integer...


Solution

  •   $items['path/yo'] = array(
        'page callback' => 'callback_function',
        'page arguments' => array("1"),
        'type' => MENU_CALLBACK,
      );
    

    See Wolfe's answer as well. If you enter (int) 1, it will be arg(1). Enter strings to be passed to the page callback as-is.