Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying to find a way to add another tab to the tabbed menu under each user's username on the user/* page.

I want to have View, Edit, and an additional link. I'm not sure where I need to be looking in the code to edit this menu and I can't find any documentation thus far. Any help would be great.

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I believe you can implement hook_menu in a custom module and use MENU_LOCAL_TASK as the type, and the path needs to start with user/

function HOOK_menu() {
  $items['user/mypage'] = array(
    'title' => t('My Tab'),
    'type' => MENU_LOCAL_TASK,
    //'page callback' => 'mymodule_mypage', //mymodule_mypage should be a function that returns HTML for the content area
    //'page arguments' => array(0, 1, 2), // 0 is arg(0), 1 is arg(1) etc...
  );
  return $items;
}

For all the array elements see this page

share|improve this answer
    
where would this code go? –  Mike May 15 '12 at 8:31
    
This code goes in a custom module. Check this page for a guide on how to write custom modules. In this case however you'll need the most basic module, you need only 2 files a .info and a .module file. The .module file will contain the above code, but the HOOK_ needs to be replaced by the module's name. For example: If mycustommodule was your custom module name the function name would be mycustommodule_menu() –  Beebee May 15 '12 at 10:12
    
When you say "//mymodule_mypage should be a function that returns HTML for the content area" what do you mean? –  Mike May 15 '12 at 18:13
    
Any function name that you put in page callback will be called when the path user/mypage is requested. You can create a new function which returns markup, or use a drupal function such as drupal_get_form etc. –  Beebee May 16 '12 at 8:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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