I'm getting 404 page not found errors when trying to access, http://mydomain/mymodule, http://mydomain/mymodule/x, or http://mydomain/mymodule/x/y

It was working but I manually cleared the cache because of an old CSS file and now it's not working. Any ideas on what happened?

I've tryed uninstalling / reinstalling my module but that didn't help either.

function mymodule_menu() {
  $items = array();

  $items['mymodule/%/%'] = array(
    'title' => 'mymodule',
    'page callback' => 'mymodule_all',
    'page arguments' => array(1, 2),
    'access arguments' => array('access mymodule'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mymodule_all($arg1,$arg2) {
  $page_content = ".....";

  return $page_content;
}

Comments

Anonymous’s picture

I think you can omit the percent (%) on the menu path since any additional arguments will automatically be passed (unless your matching wildcards) as long as you anticipate them on your callback function:

function mymodule_menu() {
  $items = array();

  $items['mymodule'] = array(
    'title' => 'mymodule',
    'page callback' => 'mymodule_all',
    'access arguments' => array('access mymodule'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mymodule_all($arg1,$arg2) {
  $page_content = ".....";

  return $page_content;
}
spanders’s picture

Hi caketoad, thanks for the tip, unfortunately that didn't work for me either.

I have a gut feeling that the code is right, and something with the way my module hooks into hook_menu got lost when I cleared the cache.

spanders’s picture

I noticed that a post regarding the MySQL table menu_router & hook_menu function that suggested enabling the devel module and running "rebuild menu". Well, I installed the devel module and that alone got my module menu items working again.

So I guess the lesson learned is when the menu isn't working quit right, install the devel module.