You are here

function tb_megamenu_get_tree in The Better Mega Menu 7

3 calls to tb_megamenu_get_tree()
tb_megamenu_get_menu_item in ./tb_megamenu.functions.inc
tb_megamenu_update_megamenus in ./tb_megamenu.functions.inc
Update items in tb_megamenus table.
template_preprocess_tb_megamenu in ./tb_megamenu.themes.inc

File

./tb_megamenu.functions.inc, line 164

Code

function tb_megamenu_get_tree($menu_name) {
  static $trees = array();
  if (!isset($trees[$menu_name])) {
    global $menu_admin;
    $sql = "\n      SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*\n      FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path\n      WHERE ml.menu_name = :menu\n      ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
    $result = db_query($sql, array(
      ':menu' => $menu_name,
    ), array(
      'fetch' => PDO::FETCH_ASSOC,
    ));
    $links = array();
    foreach ($result as $item) {
      $item['href'] = $item['link_path'];
      $links[] = $item;
    }
    $items = menu_tree_data($links);
    $node_links = array();
    menu_tree_collect_node_links($items, $node_links);
    $menu_admin = TRUE;
    menu_tree_check_access($items, $node_links);
    $menu_admin = FALSE;
    $trees[$menu_name] = $items;
  }
  return $trees[$menu_name];
}