ich finde, dieses Modul ist eine wunderbare Grundlage für DHTML-Navigationen, vielen Dank dafür.
Ich baue die Navigation von http://www.opera.com/ nach und bin auch soweit fertig. Nun möchte ich noch gerne, das die ausgewählte Hauptkategorie, dort Startseite, mit einer class="aktiv" versehen wird. Da meine PHP-Kenntnisse bescheiden sind habe ich keine Vorstellung davon, ob und wie das machbar ist. Weiss jemand von Euch Rat?
Hier ist noch einmal die Ausgabe:
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : DHTML Navi auf Spry1.6.1.-Basis
* Author(s) : Ralf Fleischer
* WWW-Adress : http://www.xtended-cooperation.de
* Mail : info@xtended-cooperation.de
* Created : 12-05-2008
* Modified : 21-05-2008, Ralf Fleischer
* ************************************************/
// include Contenido_FrontendNavigation class
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation_Breadcrumb.class.php');
$hauptkategorie = getEffectiveSetting('navigation', 'idcat-dhtml', 1);
$MaxLevel = getEffectiveSetting('navigation', 'idcat-dhtml-maxlevel', 10);
//$hauptkategorie = "CMS_VALUE[0]";
$navitems = array();
function nav_feld ($cat,$Level) {
global $client, $lang, $cfg, $idcat;
if (!is_object($db)) {
$db = new DB_Contenido;
}
$sql = "SELECT
A.idcat,
A.level,
B.parentid,
C.name
FROM
".$cfg["tab"]["cat_tree"]." AS A,
".$cfg["tab"]["cat"]." AS B,
".$cfg["tab"]["cat_lang"]." AS C
WHERE
A.idcat = B.idcat AND
B.idcat = C.idcat AND
B.idclient = '$client' AND
C.idlang = '$lang' AND
C.visible = '1' AND
A.level <= $Level AND
B.parentid = '$cat'
ORDER BY
A.idtree";
$db->query($sql);
while ( $db->next_record() ) {
$aktiv = "";
$sub_feld = nav_feld($db->f("idcat"),$Level);
if ($db->f("idcat") == $idcat) $aktiv = "active";
elseif ($sub_feld["activepath"]) $aktiv = "activepath";
$nav_feld[] = array("idcat" => $db->f("idcat"),
"name" => $db->f("name"),
"active" => $aktiv,
"sub" => $sub_feld);
if ($aktiv != "") $activepath = $aktiv;
}
$rv = array("feld" => $nav_feld,
"activepath" => $activepath);
return $rv;
}
function liste ($array, $indent = " ", $subcount = 0) {
global $last,$first,$Level,$LevelMax;
if (is_array($array["feld"])) {
if ($first) {
echo $indent . "<ul class=\"menu\">\n";
$first = 0;
}
else echo $indent ."<ul class=\"sub\">\n";
foreach ($array["feld"] as $menupunkt) {
if($subcount == 0) {
echo $indent . $indent . "<li class=\"level1-li\">\n";
} elseif($subcount == 1) {
echo $indent . $indent . "<li class=\"alone\">\n";
} else {
if($array["feld"][0] == $menupunkt) {
echo $indent . $indent . "<li class=\"first\">\n";
} elseif($array["feld"][count($array["feld"]) - 1] == $menupunkt) {
echo $indent . $indent . "<li class=\"last\">\n";
} else {
echo $indent . $indent . "<li class=\"middle\">\n";
}
}
if (is_array($menupunkt["sub"]["feld"])) {
echo $indent . $indent . $indent . "<a class=\"level1-a\" href=\"front_content.php?idcat=" . $menupunkt["idcat"] . "\">" . $menupunkt["name"] . "</a>\n";
echo $indent . $indent . $indent . "\n";
liste($menupunkt["sub"], $indent." ", count($menupunkt["sub"]["feld"]));
}
else echo $indent . $indent . $indent . "<a href=\"front_content.php?idcat=" . $menupunkt["idcat"] . "\">" . $menupunkt["name"] . "</a>\n";
echo $indent . $indent . "</li>\n";
}
echo $indent . "</ul>\n";
if($subcount != 0) {
echo $indent . "\n";
}
}
}
/* Create Navigation Array */
$navitems = nav_feld($hauptkategorie,$MaxLevel);
$first = 1;
$last = (count($navitems["feld"]))-1;
echo "<div id=\"nav\">\n";
liste($navitems);
echo "</div>\n";
?>
yui