Home ›
Have menu local tasks (view, edit, etc. tabs) show menu item description as tooltipHave menu local tasks (view, edit, etc. tabs) show menu item description as tooltip
Submitted by Benjamin Melançon on May 4, 2012 - 12:43pm
Searched words:
drupal description title tooltip in local task tabs
Most menu items in Drupal 7 show a link tool-tip, or title, but local tasks (the tabs you are most used to seeing as the edit link tab on full node pages sadly do not follow this sensible pattern.
Until Drupal core is fixed so that menu item "description" is applied to title attribute of menu tab links", here is a fix for Drupal 7. Change this to your custom theme's name (replace 'example') and drop into your theme's template.php file:
<?php
/**
* Override theme_menu_local_task().
*
* @param array $variables
* @return string
*/
function example_menu_local_task($variables) {
$link = $variables['element']['#link'];
$link_text = $link['title'];
if (!empty(
$variables['element']['#active'])) {
// Add text to indicate active tab for non-visual users.
$active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
// If the link does not contain HTML already, check_plain() it now.
// After we set 'html'=TRUE the link will not be sanitized by l().
if (empty($link['localized_options']['html'])) {
$link['title'] = check_plain($link['title']);
}
$link['localized_options']['html'] = TRUE;
$link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
}
$link['localized_options']['attributes'] = array('title' => $link['description']);
return
'<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
}
?>The key line that has been added is:
<?php
$link['localized_options']['attributes'] = array('title' => $link['description']);
?>More like this
- [unsolved] putting a query string in a menu local task tab link item
- Adding non-menu things to primary links menu items with Drupal 7's page alter hook
- Fixing Menu Block for menu items with the same path (that also have another valid path)
- Having the top-level menu items not be links (for use with dropdown menus)
- Context UI configuration menu item does not show up


Comments
Post new comment