In some way this script does it...but I cannot fix it
I took the code from another script....
Place it in frontend_render
Code: Select all
<?
function frold_menu ($struct, $act_cat_id, $level, $nav_table_struct, $link_to="index.php") {
// start with home directory for the listing = top nav structure
// 1. Build the recursive tree for given actual article category ID
// return the tree starting with given start_id (like breadcrumb)
// if the $start_id = 0 then this stops because 0 = top level
$level = intval($level);
$start_id = $act_cat_id;
while ($start_id) {
$data[$start_id] = 1;
$start_id = $struct[$start_id]["acat_struct"];
}
$temp_tree = (sizeof($data)) ? array_reverse($data, 1) : false;
foreach($struct as $key => $value) {
if($struct[$key]["acat_struct"] == $act_cat_id && $key && !$struct[$key]["acat_hidden"]) $c++;
}
$c = (!$c) ? 1 : 0;
//get depth of level
$level_depth = 0; $start_level = $level;
while ($start_level) {
$start_level = $struct[$start_level]["acat_struct"];
$level_depth++;
}
$temp_menu = build_frold_menu ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to); //starts at root level
return ($temp_menu) ? ($temp_menu) : "";
}
// -------------------------------------------------------------
function build_frold_menu ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to) {
// this returns the level structure based on given arrays
// it is special for browsing from root levels
$depth = sizeof($temp_tree)-$div; $count++;
$depth2 = $depth-$count+2;
$colspan = ($depth2 > 1) ? " colspan=\"".$depth2."\"" : "";
$temp_menu .= "";
foreach($struct as $key => $value) {
if($_SESSION["frontend_user_in"] && $struct[$key]["acat_regonly"])
$struct[$key]["acat_regonly"] = 0;
if($struct[$key]["acat_struct"] == $level && $key && !$struct[$key]["acat_hidden"] && !$struct[$key]["acat_regonly"]) {
$link = $link_to."?id=".$key.",0,0,1,0,0";
if($temp_tree[$key]) {
if($act_cat_id == $key) {
$temp_menu .= "<a class=\"active\" href=\"".$link."\">active_1".html_specialchars($struct[$key]["acat_name"])."</a>\n";
} else {
$temp_menu .= "<a class=\"active\" href=\"".$link."\">active_2".html_specialchars($struct[$key]["acat_name"])."</a>\n";
}
$temp_menu .= build_frold_menu ($struct, $key, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to);
} else {
//inactive menupunkter f.eks. når hovedsiden loades == index.php
$temp_menu .= "<a class=\"inactive\" href=\"".$link."\">".html_specialchars($struct[$key]["acat_name"])."</a>\n";
}
}
}
$temp_menu .= "";
if($nav_table_struct["row_space"] && $count == 1) $temp_menu .= $space_row;
$temp_menu1 .= "</table>";
return $temp_menu;
}
if( ! ( strpos($content["all"],'{FROLD')===false ) ) {
$content["all"] = str_replace('{FROLD}', '{FROLD:0}', $content["all"]);
$replace = 'frold_menu($content["struct"],intval($content["cat_id"]),"$1",$template_default["nav_table_struct"]);';
$content["all"] = preg_replace('/\{FROLD:(\d+)\}/e', $replace, $content["all"]);
}
?>
It works at the toplevel but when it doesnt work anymore because toplevel and sublevel links are mixed... I need first all toplevel listed and then sublevel....