template_preprocess_menu_local_action

template_preprocess_menu_local_action(&$variables)

Prepares variables for single local action link templates.

Default template: menu-local-action.html.twig.

Parameters

array $variables: An associative array containing:

  • element: A render element containing:
    • #link: A menu link array with 'title', 'url', and (optionally) 'localized_options' keys.

Related topics

Menu system
Define the navigation menus, local actions and tasks, and contextual links.

File

core/includes/menu.inc, line 65
API for the Drupal menu system.

Code

function template_preprocess_menu_local_action(&$variables) {
  $link = $variables['element']['#link'];
  $link += array(
    'localized_options' => array(),
  );
  $link['localized_options']['attributes']['class'][] = 'button';
  $link['localized_options']['attributes']['class'][] = 'button-action';
  $link['localized_options']['set_active_class'] = TRUE;

  $variables['link'] = array(
    '#type' => 'link',
    '#title' => $link['title'],
    '#options' => $link['localized_options'],
    '#url' => $link['url'],
  );
}
doc_Drupal
2016-10-29 09:46:45
Comments
Leave a Comment

Please login to continue.