Here's a simple hook_menu() question: is it possible to specify more than one MENU_NORMAL_ITEM in a hook_menu function? And if so, could someone post some simple (and if at all possible) complex examples? I'm having the most difficult time getting a module I'm writing to work with the menu system--that is, I can't get more than one MENU_NORMAL_ITEM to register with Drupal.

Comments

thomasmeadows’s picture

drupal's menus do not refresh when you add new menus while developing your module. You either need to uninstall and reinstall your module or you need to get the {devel} module for developers. Once enabled you can simply click empty cache and it will rest your menus. I am not sure if this is your issue. Otherwise, you can simply have something like this

$items['module_main'] = array(
'title' => 'Home',
'page callback' => 'function_call',
'access arguments' => array('access module main'),
'type' => MENU_NORMAL_ITEM,
);
$items['module_main/sub'] = array(
'title' => 'Sub home',
'page callback' => 'function_call2',
'page arguments' => array('function_call_argues'),
'access arguments' => array('access sub module main'),
'type' => MENU_NORMAL_ITEM,
);

chris_thecarguy’s picture

I've done the install and uninstall process, and I can't get your example to work. Thanks for the input, though. I might hash up a simple module this evening that has nothing to do with my project just to get a handle on what's going on.

nevets’s picture

Note the element 'page callback' is a callback function and that function needs to exist for the menu item to actually do anything.

chris_thecarguy’s picture

Must that item exist before Drupal will even register the menu path?

nevets’s picture

Not that I am aware of, but with out the function if you visit th page I believe you will get a 'page not found' error which makes it hard to tell apart for a 'page not found' because the path is invalid.

nevets’s picture

Which version of Drupal are you using, hook_menu() changed considerably between Drupal 5 and 6

chris_thecarguy’s picture

Drupal 6. I figure it would make the most sense to be up-to-date on what I'm using.