[development] Menu router question

Dave Cohen drupal at dave-cohen.com
Mon Jul 13 17:52:44 UTC 2009


I did something similar, changing the chatroom module so that each chat had two tabs.  I used hook_menu_alter like this...


/**
 * Implementation of hook_menu_alter().
 */
function fb_chatroom_menu_alter(&$items) {
  if ($items['chatroom/chat/%']) {
    // here I make the regular menu item a callback
    $items['chatroom/chat/%']['type'] = MENU_CALLBACK;

    // here I add a tab for the regular item
    $items['chatroom/chat/%/all'] = array(
      'title' => t('Everyone'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );

    // here I add a second tab
    $items['chatroom/chat/%/fb/friends'] = array(
      'type' => MENU_LOCAL_TASK,
      'title' => t('My Friends'),
      'page callback' => 'fb_chatroom_view_chat',
      'page arguments' => array('friends', 2),
      'access callback' => 'fb_chatroom_access_helper',
      'access arguments' => array('access chat rooms', 'friends'),
    );

  // etc for any other changes needed....
}

On Friday 10 July 2009 13:03:25 Richard Morse wrote:
> Hi! I'm trying to extend the taxonomy interface so that I can attach  
> additional information to certain terms.
> 
> I'd like to do one of two things:
> 
> - either make admin/content/taxonomy/edit/term be a MENU_DEFAULT_TASK,  
> and add additional tabs such as admin/content/taxonomy/edit/term/%/info1
> 


More information about the development mailing list