function get_elem_parents($menu, $find, $parents = array()) { for ($i = 0, $n = count($menu); $i < $n; $i++) { $elem = $menu[$i]; if ($elem["href"] == $find) { return $parents; } if (isset($elem["menu"])) { if (find_elem_in_menu($elem["menu"], $find)) { $parents[] = array("title" => $elem["title"], "href" => $elem["href"]); return get_elem_parents($elem["menu"], $find, $parents); } } } return $parents; }
<?php require_once "{$serv}{$pages_dir}/modules/breadcrumb/functions.php"; require_once "{$serv}{$pages_dir}/modules/menu/functions.php"; global $uri; $elem = find_elem_in_menu($config["menu"]["main"], $uri); if ($elem && isset($elem["parent"]) && $elem["parent"]["menu"]) { echo_menu($elem["parent"]["menu"]); } else { echo_menu($config["menu"]["main"]); }
<?php require_once "{$serv}{$pages_dir}/modules/breadcrumb/functions.php"; require_once "{$serv}{$pages_dir}/modules/menu/functions.php"; global $uri; $menu_name = "main"; if (isset($params["name"]) && isset($config["menu"][$params["name"]])) { $menu_name = $params["name"]; } $menu = (array) $config["menu"][$menu_name]; $elem = find_elem_in_menu($menu, $uri); if ($elem && $elem["menu"]) { echo_menu($elem["menu"]); }