Quick question : What's the way to get the pid for the menus implemented by my module?

More verbose : I'm writing a module that implements hook_menu, and declares a parent menu item with some number of children menu items.

I'd like to print these children menus with the menu API. I'm able to print the menus by sending the pid for the parent to menu_tree(). I got the pid from the menu administration page.

What I'm concerned about is if at some point someone with admin capacity changes the menus or deletes them, or turns off the module and turns it back on - the pid could change.

How can I get the pid for the menu implemented by my module?

Comments

jmlavarenne’s picture

I've tried $menu = menu_get_item(NULL, 'THEPATH'); but when I examine $menu, the array does not contain the menu id...

jmlavarenne’s picture

I'm feeling silly now - I got my head out of my *** and just got it from the database myself :)

$pid = db_result(db_query("SELECT mid FROM {menu} WHERE path = 'THEPATH'"));
ak’s picture

I've got the exact same problem, there's no pid in the array? Although your code isn't working for me in Drupal 6.x. What would be the recommended solution to this problem?