Rename Tabs In Drupal 5

Renaming tabs in drupal 6 is easy thanks to hook_menu_alter. In drupal 5 it's not so easy and there is no place to rename them outside of the theme system. So, let's take a look at how to rename tabs in the theme system. This method is similar to the method I outlined for removing tabs via the theme system.

First, put the following function in your template.php file.

<?php
/**
* Function renames tabs in drupal
*
* @param  $label_old
* Name of old label to replace
*
* @param  $label_new
* Name of new label to replace with
*
* @param  $vars
* $vars from _phptemplate_variables
*
*/
function phptemplate_change_tab_label($label_old, $label_new, &$vars) {
 
$tabs = explode("\n", $vars['tabs']);
 
$vars['tabs'] = '';

  foreach(
$tabs as $tab) {
    if(
strpos($tab, '>'. $label_old .'<') === FALSE) {
     
$vars['tabs'] .= $tab . "\n";
    }
    else {
     
$vars['tabs'] .= str_replace('>'. $label_old .'<', '>'. $label_new .'<', $tab) .
"\n";
    }
  }
}
?>

Then, in the function _phptemplate_variables in your template.php put something like:

<?php
function _phptemplate_variables($hook, $vars = array()) {
  if (
$hook == 'page') {
    if (
arg(0) == 'user' && is_numeric(arg(1))) {
     
phptemplate_change_tab_label('Edit', 'Edit account settings', &$vars);
    }
  }
}
?>

In this example we change the 'Edit' tab to read 'Edit account settings' and we do this only on user pages. This allows us to customize the interface and make our drupal site more usable.

Thx

Cool solution, I've tried to hack og module's tabs in a cleaner way, this is it I hope so :)

String Overrides

Another thing you could try is using String Overrides. I've had success with it in the past.... You might have to clear the cache after saving.

I like

I completely forgot about this module. Thanks for posting it here. I have an upcoming project that I think I'll use this module on.