-1

I have a custom module and in hook_menu have defined the items below.

I have created a new user tab below:

$items["user/%user/TAB"] = array(
    "title"             => t("TAB"),
    "page callback"     => "FUNCTION1",
    "page arguments"    => array(1),
    "type"              => MENU_LOCAL_TASK,
);

and several actions (showing 2 below):

$items["user/%user/TAB/ACTION"] = array(
    "title"             => t("ACTION"),
    "page callback"     => "FUNCTION1",
    "page arguments"    => array(1),
    "type"              => MENU_LOCAL_ACTION,
);

$items["user/%user/TAB/ACTION2"] = array(
    "title"             => t("ACTION2"),
    "page callback"     => "FUNCTION2",
    "page arguments"    => array(1),
    "type"              => MENU_LOCAL_ACTION,
);

New tab shows and when I click on it, I get my action links as expected. But when I click on an action, I lose the tabs! The breadcrumb is accurate but no tabs.

How do I keep the user tabs?

  • Perhaps you should define a root item first. E.g. $items["user/%user/myroot"] $items["user/%user/myroot/TAB"] – undersound Jun 28 '14 at 20:08
  • can you elaborate? – Scott Joudry Jun 28 '14 at 22:21
  • Unrelated: You should not use t() inside hook_menu(). Instead, just type the literal title in English. The default title callback is t(), so all your titles will go through t() automatically. – donquixote Jun 29 '14 at 1:40
0

I feel stupid that it took me so long to try this:

$items["user/%user/TAB/ACTION"] = array(
    "title"             => t("ACTION"),
    "page callback"     => "FUNCTION1",
    "page arguments"    => array(1),
    "type"              => MENU_DEFAULT_LOCAL_TASK,
);

$items["user/%user/TAB/ACTION2"] = array(
    "title"             => t("ACTION2"),
    "page callback"     => "FUNCTION2",
    "page arguments"    => array(1),
    "type"              => MENU_LOCAL_TASK,
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.