Drupal7 - How to rename the edit tab of a node

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

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x