How to hide Edit | View tabs?

后端 未结 11 989
轮回少年
轮回少年 2021-02-01 04:43

Can I hide the

Edit | View

tabs on top of each node ?

I\'ve searched for this option in theme settings (both global and sta

相关标签:
11条回答
  • 2021-02-01 05:28

    For all the people stumbling upon this question while looking for a D7 solution: As stated on https://drupal.stackexchange.com/a/77964/15055 it's hook_menu_local_tasks_alter()

    /**
     * Implements hook_menu_local_tasks_alter() to unset unwanted tabs
     */
    function MYMODULE_menu_local_tasks_alter(&$data) {
      foreach ($data['tabs'][0]['output'] as $key => $value) {
        if ($value['#link']['path'] == 'node/%/view') {
          unset($data['tabs'][0]['output'][$key]);
        }
      }
    }
    
    0 讨论(0)
  • 2021-02-01 05:29

    there is a module for that: tab tamer allows to hide or disable tabs and rename them as well.

    0 讨论(0)
  • 2021-02-01 05:29

    The simplest solution to hide the tabs is to add this class in your theme css

    .tabs{ display:none;}
    
    0 讨论(0)
  • 2021-02-01 05:31

    I use the following in template.php by theme (which is perhaps a little hacky, I feel I should be considering unsetting $tabs instead):

    function THEME_NAME_menu_local_tasks() {
      return '';
    }
    

    Or you could ommit:

    if ($tabs) echo $tabs;
    

    from your page.tpl.php...

    0 讨论(0)
  • 2021-02-01 05:34

    This is not the answer to the question of what the author asked. But somehow it might be useful for others user who facing the similar problem with me. Please let me know if this is not suitable to put in here.

    I get the answer from @grayside and modified a bit to hide the view | edit tab from node based on the content type I want.

        function MYMODULE_menu_alter(&$items) { 
          $items['node/%node/view']['access callback'] = 'MYMODULE_disable_node_view';
          $items['node/%node/view']['access arguments'] = array(1); 
        } 
    
        function MYMODULE_disable_node_view($node){
          if($node->type == 'product'){
            return false;
          }
        }
    

    product is the machine name of my content type, I don't want anywant to access it including root user.

    0 讨论(0)
提交回复
热议问题