You are here

function theme_menu_fields_menu_tree in Menu Item Fields 7

Theme a menu tree.

Parameters

array $variables: Array where the variables are located.

Return value

string The children attributes list.

File

./menu_fields.module, line 252
Main file contain hooks/functions.

Code

function theme_menu_fields_menu_tree(array $variables) {

  // We check here, if this is the rendering of a single link element as part
  // of a menu fields entity. In that case, the markup has no <li> element and
  // doesn't need the wrapping <ul> neither.
  // The criteria is that their is only a single item in the menu, the menu
  // itself is menu_fields enabled and it's not the rendering of the entity
  // itself (render_menu_fields == FALSE) which could be the case for single
  // link menus.
  $first_item = reset($variables['tree']);
  $link = $first_item['#original_link'];
  $render_plain = !isset($link['render_menu_fields']) || $link['render_menu_fields'] === FALSE;
  $menu_fields_enabled = menu_fields_is_enabled_menu($link['menu_name']);
  $single_item = count(element_children($variables['tree'])) == 1;
  if ($render_plain && $menu_fields_enabled && $single_item) {
    return $first_item['#children'];
  }
  return '<ul class="menu">' . $variables['tree']['#children'] . '</ul>';
}