1 menu.inc template_preprocess_menu_tree(&$variables)

Implements template_preprocess_HOOK() for theme_menu_tree().

Related topics

File

core/includes/menu.inc, line 1768
API for the Backdrop menu system.

Code

function template_preprocess_menu_tree(&$variables) {
  $variables['#tree'] = $variables['tree'];

  $variables['attributes'] = array();
  if (isset($variables['tree']['#wrapper_attributes'])) {
    $variables['attributes'] = $variables['tree']['#wrapper_attributes'];
  }

  // Only add the menu class to the first level of depth.
  if ($variables['tree']['#depth'] === 0) {
    $variables['attributes']['class'][] = 'menu';
  }

  $variables['depth'] = $variables['tree']['#depth'];
  $variables['tree'] = $variables['tree']['#children'];
}