Drupal7 - How to rename the edit tab of a node

User login

Here's a snippet that will rename the edit tab to a custom string, on node edit, depending on the content type.

It is easy to add different or additional validation criteria, depending on when you would like the Edit tab to show up with its brand new name.

This code should be placed in a custom module.

<?php
/**
* Implements hook_menu_alter().
* Rename Edit tab to a custom string
*/
function example_menu_alter(&$items) {
 
$items['node/%node/edit']['title callback'] = 'example_edit_tab_title';
 
$items['node/%node/edit']['title arguments'] = array(1);
}
/**
* The title callback for the edit tab. Rename Edit to SomeName, if the node is of content type contentTypeMachineName
*/
function example_edit_tab_title($node) {
  if (
$node->type == 'contentTypeMachineName') {
    return
t('SomeName');
  }
  else {
   
// A value needs to be specifically returned, otherwise a blank value will come up.
   
return t('Edit');
  }
}
?>

Tags: 
Drupal 7, Drupal Quick Tips