Override the title of a Menu Item (Local task)

lee20 - January 30, 2008 - 04:39

I'd like to change the title of a menu item that is defined in a core module (specifically in taxonomy.module). I want to change the "Add term" local task to "Add category". Is there a (right) way to do this without changing it directly in the module? I think I could probably use i18n to solve this issue, but I don't believe this is how i18n is meant to be used, plus that is overkill for changing a single title.

I have tried creating a custom menu item through the menu administration; this does actually change the name but causes two tabs to appear (both with the right title). Disabling the item has no affect, both tabs still appear.

I have also tried redefining the menu item in a custom module (with the proper title), but it this gets overwritten by the menu item defined in the taxonomy module.

Any help is appreciated. Thanks!

theme_menu_item_link?

Jody Lynn - January 30, 2008 - 16:02

I need to do a similar thing. I think I'm going to try implementing a theme_menu_item_link in template.php and having it doing something like if ($item['title'] == 'old-title') {$item['title'] = 'new-title'; }

Yes, that worked

Jody Lynn - January 30, 2008 - 16:07

In my case the local task I wanted to override was called 'Orders' and I changed both its title and description.

function phptemplate_menu_item_link($item, $link_item) {
  if ($item['title'] == 'Orders' && $item['description'] == t('View your order history.')) {
    $item['title'] = 'Credits';
    $item['description'] = t('Buy credits and view your order history.');
  }
  return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}

It's not pretty but it does

lee20 - January 30, 2008 - 16:42

It's not pretty but it does the trick and prevents hacking the core. Thanks for the help!

String overrides

Jody Lynn - February 4, 2008 - 17:47

There is a brand new awesome way to override all kinds of strings like this now: http://drupal.org/project/stringoverrides

 
 

Drupal is a registered trademark of Dries Buytaert.