template_preprocess_menu_local_task(&$variables)
Prepares variables for single local task link templates.
Default template: menu-local-task.html.twig.
array $variables: An associative array containing:
function template_preprocess_menu_local_task(&$variables) { $link = $variables['element']['#link']; $link += array( 'localized_options' => array(), ); $link_text = $link['title']; if (!empty($variables['element']['#active'])) { $variables['is_active'] = TRUE; // Add text to indicate active tab for non-visual users. $active = SafeMarkup::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)'))); $link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active)); } $link['localized_options']['set_active_class'] = TRUE; $variables['link'] = array( '#type' => 'link', '#title' => $link_text, '#url' => $link['url'], '#options' => $link['localized_options'], ); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!menu.inc/function/template_preprocess_menu_local_task/8.1.x