2

How can I add same callback to 2 different menus?

function my_callback_menu(){
  $items = array();
  $items['my_callback'] = array(
    'title'            => t('My title'),    
    'menu_name'        => 'menu-my-menu',   
        'page callback'    => 'my_callback',         
        'access arguments' => array('access content'),            
  );
  return $items;
}
bert
  • 287
  • 6
  • 14

2 Answers2

0

There are now a couple of solutions to this:

The module multiple_node_menu answers the question without the hook. On a node you are able to put a menu item in two places and set the primary parent (router).

There is also Node Symlinks which works differently allowing the same content to be displayed in two different places in the website without an SEO penalty. (not what I was looking for)

Duncanmoo
  • 3,535
  • 2
  • 31
  • 32
0

You can create as many menu items with hook_menu as you want. All of them can be assigned to the same callback function if you make the page callback value the same name.

googletorp
  • 33,075
  • 15
  • 67
  • 82
  • You might want to find a way to wipe the redundant page from the search index. You might check the search_config module. – Grayside Apr 22 '10 at 06:43
  • @Grayside I'm not saying you should do this, or even that it's a good idea, only that it's possible. Also the same callback function can provide different output if you use arguments, so it might not even be an issue. – googletorp Apr 22 '10 at 13:28