3

How can I override link title in the local tasks menu?

I tried like this, but didn't work:

function mymodule_menu_local_tasks_alter(&$data, $route_name) {
  // Override 'Revisions' label menu link
  $data['tabs'][0]['entity.node.version_history']['#link']['localized_options']['attributes']['title'] = t('View history');
}
3

I have had success with

$data['tabs'][0]['entity.node.canonical']['#link']['title'] = t('Overview');
1

For Drupal 8, this is what worked for me. I also adjusted the weights so I could re-order the items.

/**
 * Implements hook_local_tasks_alter().
 *
 * @inheritdoc
*/
function mymodule_local_tasks_alter(&$local_tasks) {

  $local_tasks['entity.user.canonical']['title'] = 'Account Details';
  $local_tasks['entity.user.canonical']['weight'] = -3;

  $local_tasks['entity.user.edit_form']['title'] = 'Edit Account';
  $local_tasks['entity.user.edit_form']['weight'] = -2;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy