Search code examples
phpdrupalhook-menu

Drupal module menu item not showing in menu primary-links


I'am trying to get a menu item to show in the 'primary-links'.

i've read this, but that is not working. What am I doing wrong?

/**
 * Implementation of hook_menu().
 */
function modulename_menu() {
    $items = array();

    $items['test'] = array(
            'title' => t('test'),
            'description' => 'some description',
            'page callback' => 'modulename_function',
            'access callback' => TRUE,
            'type' => MENU_NORMAL_ITEM,
            'menu_name' => 'primary-links',
    );

    return $items;
}

So i would expect 'test' to show up next to my other primary-links.

I added the 'primary-links' block to the header and logged in as user/1 but still the 'test' link is not showing in the menu or header bar.

Using Drupal 6.x with the Garland theme.


Solution

  • When adding module menus, you have to either manually run the menu_rebuild() function or visit the modules page at admin->build->modules (visiting this page runs the menu_rebuild function) and then clear the cache. It seems that Drupal should just show the menu items as they are added, but even with caching off they are cached: caching only applies to content. This has to be done every time a menu item is added or changed.

    To sum:

    1. Hard refresh on the modules page
    2. Clear the cache.

    This guy has written about it as well: http://data.agaric.com/node/1818