1

I am using views to create a menu tab for my views page and it works fine accept it comes with two unexpected tabs: Tasks and Index, which are showed in the photo below. Is there any way to remove them? Thanks.

enter image description here

1 Answer 1

1

You can achieve this using hook_menu_local_tasks_alter hook.

Alter tabs and actions displayed on the page before they are rendered.

function hide_tabs_menu_local_tasks_alter(&$data) {
    foreach ($data['tabs'][0]['output'] as $key => $value) {
        if ($value['#link']['path'] == "check your path") {
          unset($data['tabs'][0]['output'][$key]);
        }
    }
}

You can also take a look on Tab Tamer module.

Tab Tamer is an administration utility that provides easy re-ordering, hiding, and deactivation of tabs and subtabs. You can also rename tab labels.

Tab Tamer makes use of Drupal's drag ordering, but degrades gracefully when javascript is disabled.

Tab Tamer utilizes Drupal's cache system to help conserve server resources.

4
  • Ok. Thanks for your reply. Could you please explain abit more details of how can I add the hook?
    – Tony
    Sep 17, 2016 at 10:02
  • you can create a custom module or can place it on themes template.php file.
    – DRUPWAY
    Sep 17, 2016 at 10:08
  • Read drupal.org/node/295381
    – DRUPWAY
    Sep 17, 2016 at 10:12
  • I have made a module to hide the Tasks tab but it is not working. This is the code function remove_tab_menu_local_tasks_alter(&$data) { foreach ($data['tabs'][0]['output'] as $key => $value) { if ($value['#link']['path'] == "/admin") { unset($data['tabs'][0]['output'][$key]); } } }
    – Tony
    Sep 19, 2016 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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