views:

32

answers:

2

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.

+1  A: 

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

Andrew Sledge
thnx! i visited admin/build/modules than cleared the cache using the devel module and the link is showing up :) I did not know that you had run the menu_rebuild() function.
FLY
Yeah, it kinda sucks but they did that for performance reasons.
Andrew Sledge
A: 

As said in a comment at Andrews link.

using the devel module and using the 'Rebuild menus' link is an even more easyer way It basicly does the same, but it now only takes you one mouse click ;)

If you don't have devel installed, go and install it! It is ha handy (or must have) tool if your developing modules.

FLY