2

Can you please help me to hide the tabs from the Find/Add/Edit content page?

edit content

Find content

Is there a way to programmatically hide them?

2 Answers 2

6

A more generic solution could be Tab Tamer.

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

4
  • Thanks @Potney Switters.. Sorry I don't want to use any other module.. I need a solution to solve this in programmatic way
    – Mr. Black
    Aug 22, 2013 at 8:26
  • 1
    @Mr.Black Well, you can just look at the module and see how it is doing it. I guess you should look for menu_alter. Or read first result I got from Google.
    – Mołot
    Aug 22, 2013 at 8:34
  • 2
    @Mr.Black To programmatically remove tabs, you still need a module. Whatever is one created by you, or one created by others, it doesn't make any difference: It still is an extra module. The only difference would be when you have already a custom module; even in that case, putting all in a single module would be a bad idea.
    – apaderno
    Aug 22, 2013 at 8:55
  • @Molot Thank you for your suggestion.. Anyway I'll be looking the code on the same. Thanks.
    – Mr. Black
    Aug 22, 2013 at 9:08
5

To hide the menu tabs you want to hide, you just need to create a module containing the following code.

function mymodule_menu_alter(&$items) {
  $paths = array('admin/content/comment', 'node/%node/view');

  foreach ($paths as $path) {
    $items[$path]['type'] = MENU_CALLBACK;
  }
}

I would rather follow Potney Switters's suggestion, and install the Tab Tamer module, since:

  1. It implements a user interface to change which tabs should be hidden; this is better than hard coding paths in the code
  2. It doesn't force you to find which module implements which tab, and get the path from the code of that module
  3. It doesn't require too much resources
  4. It is code that you don't maintain, so you don't need to port it to Drupal 8 because somebody else will do it

The last point could also mean you need to wait to upgrade to Drupal 8 until the Tab Tamer module is ported to Drupal 8, but since you are probably using other third-party modules, that should not be a problem.
Of all the points I listed, I think the first two are the reason why it is worth using the Tab Tammer module. The only reason not to use that module would be using a less resource-consuming module, which would also mean using a module that uses less code, including the one used for the settings page; that would mean having hard-coded settings, with the consequences reported in the second point.

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.