문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top