Search code examples
phpdrupaldrupal-6drupal-7drupal-modules

Drupal - How to change the default view/edit operation Name of a content type


I am using drupal 7. First please refer my screen shot to get what i am talking about. http://www.karya.gisla.in/scr.png

Lets say my content type is article. when we create a article, for authenticated users, the node displayes primary tabs namely : View and Edit. I just want to change/edit it to say :View Article and Edit Article.

Note: Just for a specific content type only. i.e other content type say Page will display as default : View and Edit.

Any ideas how to achieve this.

Any help will be appreciated.


Solution

  • The following code does the trick. Paste it in your themes template.php and change YOURTHEMENAME to... your theme's name. maybe use dpm($vars) in this function to have a look which kinds of information in $vars is. This should help you getting to the point even faster next time.

    [EDIT:] Thanks Ben for pointing that out! Here's an updated version:

    function YOURTHEMENAME_preprocess_page(&$vars) {
      if ($vars['node']->type == 'article') {
        foreach($vars['tabs']['#primary'] AS $index => $tab) {
          if($tab['#link']['title'] == t('View')) {
            $vars['tabs']['#primary'][$index]['#link']['title'] = t('View Article');
          }
    
          if($tab['#link']['title'] == t('Edit')) {
            $vars['tabs']['#primary'][$index]['#link']['title'] = t('Edit Article');
          }
        }
      }
    }
    

    Have fun, Martin