3

I've got a custom module which I use to define some urls that are used for a json api. I don't want them to show up in the Navigation menu. How do I change my hook_menu configuration so these urls are excluded from the menu?

Here is an example of two of my menu items that I want to hide, and a third one I would like to be visible:

$items['mymodule/1/login'] = array(
    'page callback' => 'mymodule_login',
    'access callback' => TRUE,
);
$items['mymodule/1/signup'] = array(
    'page callback' => 'mymodule_signup',
    'access callback' => TRUE,
);
$items['mymodule_bulkupload'] = array(
    'title' => 'Bulk Upload',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymoduleapi_form_bulkupload'),
    'access callback' => 'mymoduleapi_user_is_mymodule_owner',
);

I end up getting a bunch of empty items in my Nav menu. I would like to be able to hide those api menu items.

enter image description here

How do I control that from within hook_menu?

4

I think what you need is MENU_CALLBACK in 'type.

It's for hidden items like API calls that don't want to go in menus

https://api.drupal.org/api/drupal/includes%21menu.inc/constant/MENU_CALLBACK/7

| improve this answer | |
  • I tried that and flushed the cache, to make sure it reloaded my hook_menu, but nothing changed in the menu. – Kenny Wyland Jul 30 '14 at 19:47
  • Actually, disabling and re-enabling the module caused them to disappear. I guess that menu isn't re-evaluated during a cache flush. hmm. – Kenny Wyland Jul 30 '14 at 19:53
  • 1
    Had the same issue: If you edit the menu, disable the item and then hit "reset" on the menu item, it will disappear too. – MrUpsidown Mar 23 '15 at 10:25
  • For see the change, is better change the url and change the type key to MENU_CALLBACK, clear cache and again change to the original url, clear cache and then it will work! – rpayanm Oct 21 '15 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.