2

I'm new to Drupal and about to write my first custom module ("configurator") with help of the drupal documentation.

I've implemented the menu hook:

function configurator_menu()
{
    $items = array();
    $items['configurator'] = array(
        'title' => 'Configurator',
        'page callback' => 'configurator_init',
        'access callback' => TRUE, 
        'type' => MENU_CALLBACK,
     );
     return $items;
}

function configurator_init()
{
    return "<p> Hello World </p>";
}

At "Administer > Site Building > Modules" the module is shown and activated. Cache has been cleared, but somehow the menu item for my "configurator" module is not showing up.

Why?

3

You've either forgotten to set the menu_name key for the menu you want to add the link to:

$items['configurator'] = array(
  'title' => 'Configurator',
  'page callback' => 'configurator_init',
  'access callback' => TRUE, 
  'type' => MENU_CALLBACK,
  'menu_name' => 'primary-links',
);

Or you want to use the default ('navigation'), but you're using the wrong type. It should be

$items['configurator'] = array(
  'title' => 'Configurator',
  'page callback' => 'configurator_init',
  'access callback' => TRUE, 
  'type' => MENU_NORMAL_ITEM,
);

MENU_CALLBACK is:

Callbacks simply register a path so that the correct function is fired when the URL is accessed. They are not shown in the menu.

Emphasis mine.

| improve this answer | |

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.