My module provides a 'user/%user/reports' link via hook_menu. Also a custom menu is added in mymodule.install file just like menu module itself does it (insert to menu_custom).
When I declare a 'menu_name' option for my link, it doesn't work. I see it in Navigation menu instead. That is probably because of 'user/' part in it. When I change module-provided link to simply 'reports', it appears in my menu instantly. How can I change menu for this link programmatically, without admin interface? And is it a bug or normal behaviour?

Comments

jaypan’s picture

I can't even get menu_name to work for a top level link. I have created a top level url at www.example.com/kairanban. I created a custom menu called top-menu, and I added the block to my site. All the links that I have manually added show up fine, but the link I added to this menu in hook_menu does not work. I have defined it like this:

function kairanban_menu()
{
  $menu['kairanban'] = array
  (
    'menu_name' => 'top-menu',
    // rest of menu definition 
  );
  return $menu;
}

The link is properly added to navigation if I don't add 'menu_name', so I know the rest of my menu definition is fine, but it doesn't appear when I put it in the custom menu.

dreamdust’s picture

Status: Active » Closed (works as designed)

Figured this out! It's extremely counter-intuitive.

Drupal 6's menu system doesn't evaluate %user into links, you have to use %user_uid_optional instead.

This makes no sense to me, but I finally discovered it after looking in user.module.