Hey all,

I'm trying to add custom tabs to the user interface such as "add child category" and the like. Unfortunetly drupal (when edit hook_menu) designates where tabs go based on the actual path they send someone too. so "node/ arg(1) /whatever" is the only format links can be in. Is there a way to bypass this, or at least other options, suchs as "node/add/category-cat/parent/arg(1)" ?

If anyone has a solution it would be well appreciated.

Thanks

Comments

nevets’s picture

I have modules that add other tabs, I just use a path of the form node/{NID}/whatever, example: node/23/listings. This works perfectly fine so I am wonder if you are experiencing a problem or just want them different (which will not work given the way menues (which includes tabs) are built up based on the path.

mooffie’s picture

Unfortunetly drupal (when edit hook_menu) designates where tabs go based on the actual path they send someone too. so "node/ arg(1) /whatever" is the only format links can be in. Is there a way to bypass this

You can't bypass this, but you can redirect in your callback function. For example, the following module, mytabs, does what you want. I write it from memory and syntax errors are likely.

function mytabs_menu($may_cache)
{
  $items = array();
  if (!$may_cache) {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $items[] = array(
        'path' => 'node/'. arg(1) .'/addchildcat',
        'callback' => 'mytabs_addchildcat',
        'title' => t('add child category'),
        'access' => TRUE,
        'type' => MENU_LOCAL_TASK
      );
    }
  }
  return $items;
}

function mytabs_addchildcat() {
  drupal_goto('node/add/category-cat/parent/'. arg(1));
}

Save to 'mytabs.module', drop in your modules direcory and enable.