Hi,

I am registering a path via hook_menu_alter but when I access relevent path, drupal doesn't invoke correct callback but instead fallback to other parent url. Here is snippet

<?php
function mainlist_menu_alter(&$items) {

 
$items['user/%user/categories/bird/list/%/slot']  = array(
     
'page callback'  => 'mainlist_invalid_slot',
     
'page arguments' => array(1, 5),
     
'access callback'=> TRUE,
     
'type' => MENU_CALLBACK,
  );
 
 
$items['user/%user/categories/bird/list/%/slot/%']  = array(
     
'page callback'  => 'mainlist_slot',
     
'page arguments' => array(1, 5, 7),
     
'access callback'=> TRUE,
     
'type' => MENU_CALLBACK,
  );
}



function
mainlist_invalid_slot($account, $mainlist) {
 
drupal_set_message('Invalid slot access attempt!', 'error');
  return
drupal_not_found();
}

function
mainlist_slot($account, $mid, $species)
{
 
dsm(func_get_args());
  return
t("Hello");
}
?>

Ideally when I go to url http://dev/user/1/categories/bird/list/2/slot/121 mainlist_slot callbac kshould have been called but actually mainlist_invalid_slot is called.
I have other items in alter hook but only this particular is causing problem, other get invoked rightly as expected.

Comments

I am registering a path via

I am registering a path via hook_menu_alter

Why hook_menu_alter..? Instead use hook_menu, if you are registering new path.
Also don't forget to clear the caches :)

-- tanmay

I had this problem once

I had this problem once aswell, it could be that the url is allready matched with the menu mainlist_invalid_slot.

easiest solution is probally to check all your incomming values, something like this:

<?php
function mainlist_menu_alter(&$items) {
 
$items['user/%user/categories/bird/list/%/slot/%']  = array(
     
'page callback'  => 'mainlist_slot',
     
'page arguments' => array(1, 5, 7),
     
'access callback'=> TRUE,
     
'type' => MENU_CALLBACK,
  );
}

function
mainlist_invalid_slot($account, $mainlist) {
 
drupal_set_message('Invalid slot access attempt!', 'error');
  return
drupal_not_found();
}

function
mainlist_slot($account, $mid, $species)
{
  if(empty(
$species)) {
    return
mainlist_invalid_slot($account, $mid);
  }
 
dsm(func_get_args());
  return
t("Hello");
}
?>