2

I want to create an additional tab (dashboard) on my site's user profile page. There is a Homebox module installed and a dashboard was created for users. The dashboard is accessible by user/dashboard. How can I do this? I tried doing it as below:

  1. New module created with name add_menu_tab
  2. In add_menu_tab.module file I wrote as below I want to create an additional tab (dashboard) on my site's user profile page. There is a homebox module installed and a dashboard was created for users. The dashboard is accessible by user/dashboard. How can I do this? I tried doing it as below:

  3. New module created with name add_menu_tab

  4. In add_menu_tab.module file I wrote as below:

code :

function add_menu_tab_menu() {
     $items['user/dashboard'] = array(
    'title' => 'Dashboard',
      'type' => MENU_LOCAL_TASK,
      'weight' => 7
    );
    return $items;
  }

The menu is still not visible in user profile What should I do?

  • Have you cleared menu cache? It's what I usually forget to do. – Mołot Sep 4 '13 at 7:29
  • I surely cleared menu cache... Still the menu tab is not visible in user profile page... – Ebbin Jose Sep 4 '13 at 7:34
2

You should implement hook_menu_alter() instead of hook_menu.

function add_menu_tab_menu_alter(&$items) {
  $items['user/dashboard']['type'] = MENU_LOCAL_TASK;
}

Then you should clear the cache, at least the menu cache, as Mołot suggested.

There is also another approach using hook_menu_local_tasks_alter(). But the first method is better since it is called only once, after the hook_menu and saved in the database, while the latter is being called each time the local tasks are rendered.

2

As you said dashboard is created and accessible in user/dashboard ,all you need to do is in your custom module altering menu by hook_menu_alter (menu alter API) and changing the menu type to MENU_LOCAL_TASk .

function yourmodule_menu_alter(&$items){
  $items['user/dashboard']['type'] = MENU_LOCAL_TASK;
}

Remember to clear cache afterward ;)

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.