function theme_menu_local_tasks

You are here

7 menu.inc theme_menu_local_tasks(&$variables)
4.6 menu.inc theme_menu_local_tasks()
4.7 menu.inc theme_menu_local_tasks()
5 menu.inc theme_menu_local_tasks()
6 menu.inc theme_menu_local_tasks()
8 menu.inc theme_menu_local_tasks(&$variables)

Returns HTML for primary and secondary local tasks.

Parameters

$variables: An associative array containing:

  • primary: (optional) An array of local tasks (tabs).
  • secondary: (optional) An array of local tasks (tabs).

See also

menu_local_tasks()

Related topics

File

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

Code

function theme_menu_local_tasks(&$variables) {
  $output = '';

  if (!empty($variables['primary'])) {
    $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
    $variables['primary']['#prefix'] .= '<ul class="tabs primary">';
    $variables['primary']['#suffix'] = '</ul>';
    $output .= drupal_render($variables['primary']);
  }
  if (!empty($variables['secondary'])) {
    $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
    $variables['secondary']['#prefix'] .= '<ul class="tabs secondary">';
    $variables['secondary']['#suffix'] = '</ul>';
    $output .= drupal_render($variables['secondary']);
  }

  return $output;
}

Comments

Why aren't primary and secondary broken out into separate functions normally? This seems a bit counter-intuitive to the rest of the theme layer.

<?php
function MYTHEME_menu_local_tasks(&$variables) {
  if (isset(
$variables['primary'])) {
    foreach(
$variables['primary'] as $menu_item_key => $menu_attributes) {
   
$variables['primary'][$menu_item_key]['#link']['localized_options'] = array(
     
'attributes' => array('class' => array('colorbox-load')),
    );
    }
  }
  return
theme_menu_local_tasks($variables);
}

?>

Or, in case there already are localized options:

<?php
function MYTHEME_menu_local_tasks(&$variables) {
  if (isset(
$variables['primary'])) {
    foreach(
$variables['primary'] as $menu_item_key => $menu_attributes) {
     
$variables['primary'][$menu_item_key]['#link']['localized_options']['attributes']['class'][] = 'colorbox-load';
    }
  }
  return
theme_menu_local_tasks($variables);
}
?>