Posted: Mon 21. Mar 2005, 10:16
mmmh,
i use this:
to get this:
it's not 100% valid at the moment, but it works very well.
hope this helps you a little bit...
i use this:
Code: Select all
// -------------------------------------------------------------
// css nav {NAV_LIST_ALL} using <div> tags
// -------------------------------------------------------------
function css_list_all ($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_levels_list ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to); //starts at root level
return ($temp_menu) ? ("\n<div id=\"navcontainer\">".$temp_menu."</div>\n") : "";
}
// -------------------------------------------------------------
function build_levels_list ($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;
$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_image_id = "linkid".randpassword(6);
$link_name_id = ' name="'.$link_image_id.'" id="'.$link_image_id.'"';
$link = $link_to."?";
$link .= ($struct[$key]["acat_alias"]) ? html_specialchars($struct[$key]["acat_alias"]) : 'id='.$key.',0,0,1,0,0';
$mycategory = $GLOBALS['content']['struct'][$key]['acat_alias'];
/*I use the alias names of the root-levels and made custom classes for each*/
/*Here the tree is build and compare if active section or root level etc*/
if($temp_tree[$key]) {
if($act_cat_id == $key && !$count>0) {
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\" ><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\" class=\"MenuItem-".$mycategory."\" >".html_specialchars($struct[$key]["acat_name"])."</a>";
} else {
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\"><a id=\"activeSection\" href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\" class=\"MenuItem-".$mycategory."\">".html_specialchars($struct[$key]["acat_name"])."</a>";
}
$temp_menu .= build_levels_list ($struct, $key, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to);
} else {
if($count == 1){
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\" class=\"MenuItem-".$mycategory."\" >".html_specialchars($struct[$key]["acat_name"])."</a>";
} else {
$temp_menu .= "<li class=\"MenuItem-lvl-".$count."\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\">".html_specialchars($struct[$key]["acat_name"])."</a>";
}
$temp_menu .= "</li>";
}
/* the orginal---------------------------------------------
if($temp_tree[$key]) {
if($act_cat_id == $key) {
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\" id=\"activeSection\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\">".html_specialchars($struct[$key]["acat_name"])."</a></li>\n";
} else {
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\">".html_specialchars($struct[$key]["acat_name"])."</a></li>\n";
}
$temp_menu .= build_levels_list ($struct, $key, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to);
} else {
if($count == 1){
$temp_menu .= "<li class=\"MenuItem-".$mycategory."\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\">".html_specialchars($struct[$key]["acat_name"])."</a></li>\n";
} else {
$temp_menu .= "<li class=\"MenuItem-lvl-".$count."\"><a href=\"".$link."\" title=\"".html_specialchars($struct[$key]["acat_name"])."\">".html_specialchars($struct[$key]["acat_name"])."</a></li>\n";
}
} */
}
}
if($temp_menu) {
/**/$myg = '<ul ';
if($count>0) {$myg .= 'class ="navlist"';}
$myg .= ">".$temp_menu.'</ul>';
/* $myg = "<ul>\n".$temp_menu.'</ul>'; */
$myg .= "\n";
}
return $myg;
}
// ------------------------------ -------------------------------
// <ul>-list based Navigation table
if( ! ( strpos($content["all"],'{NAV_LIST_ALL')==false ) ) {
$content["all"] = str_replace('{NAV_LIST_ALL}','{NAV_LIST_ALL:0}',$content["all"]);
$replace = 'css_list_all($content["struct"],intval($content["cat_id"]),"$1",$template_default["nav_table_struct"]);';
$content["all"] = preg_replace('/\{NAV_LIST_ALL:(\d+)\}/e', $replace, $content["all"]);
}
Code: Select all
<div id="navcontainer">
<ul class="navlist">
<li class="MenuItem-buergerservice-stadtverwaltung"><a id="activeSection" href="buergerservice-stadtverwaltung.phtml" title="Bürgerservice + Stadtverwaltung" class="MenuItem-buergerservice-stadtverwaltung" name="activeSection">Bürgerservice + Stadtverwaltung</a>
<ul class="navlist">
<li class="MenuItem-lvl-2"><a href="die_stadtverwaltung.phtml" title="Die Stadtverwaltung">Die Stadtverwaltung</a></li>
<li class="MenuItem-buergerservice-scheibenberg"><a id="activeSection" href="buergerservice-scheibenberg.phtml" title="Bürgerservice" class="MenuItem-buergerservice-scheibenberg" name="activeSection">Bürgerservice</a>
<ul class="navlist">
<li class="MenuItem-lvl-3"><a href="die_aemter.phtml" title="Die Ämter">Die Ämter</a></li>
<li class="MenuItem-lvl-3"><a href="bekanntmachungen.phtml" title="Öffentliche Bekanntmachungen">Öffentliche Bekanntmachungen</a></li>
<li class="MenuItem-lvl-3"><a href="formulare.phtml" title="Formulare">Formulare</a></li>
</ul>
</li>
<li class="MenuItem-lvl-2"><a href="fakten_zu_scheibenberg.phtml" title="Fakten">Fakten</a></li>
</ul>
</li>
<li class="MenuItem-tourismus-wandern"><a href="tourismus-wandern.phtml" title="Tourismus + Wandern" class="MenuItem-tourismus-wandern">Tourismus + Wandern</a></li>
<li class="MenuItem-kultur-geschichte"><a href="kultur-geschichte.phtml" title="Kultur + Geschichte" class="MenuItem-kultur-geschichte">Kultur + Geschichte</a></li>
<li class="MenuItem-landschaft-natur-umwelt"><a href="landschaft-natur-umwelt.phtml" title="Landschaft + Umwelt" class="MenuItem-landschaft-natur-umwelt">Landschaft + Umwelt</a></li>
<li class="MenuItem-bildung-soziales-religion"><a href="bildung-soziales-religion.phtml" title="Bildung + Soziales + Religion" class="MenuItem-bildung-soziales-religion">Bildung + Soziales + Religion</a></li>
<li class="MenuItem-wirtschaft"><a href="wirtschaft.phtml" title="Wirtschaft" class="MenuItem-wirtschaft">Wirtschaft</a></li>
<li class="MenuItem-"><a href="18.0.0.1.0.0.phtml" title="Intern" class="MenuItem-">Intern</a></li>
</ul>
</div>
hope this helps you a little bit...