Hallo Leute,
habe mir eine kleine Navigation gebastelt, die es bis jetzt ermöglicht, die 2. Ebene auszulesen und in der Navi anzuzeigen.
Jetzt würde ich aber gerne, dass die 2. Ebene erst angezeigt wird, wenn man auf die 1. Ebene (Parent) klickt erscheint.
Ich weiss das dies nur eine kleine Codefolge ist, aber leider habe ich keine Ahnung mehr wie das wo mit den Schleifen ist.
Hier aber mal der Code:
PHP-Code:
<?php
// EXPLODE PATH
$PATH = explode("|",$this->getValue("path").$this->getValue("article_id")."|");
// GET CURRENTS
$path1 = $PATH[1];
$path2 = $PATH[2];
$path3 = $PATH[3];
/* START 1st level categories */
$navLeftCol .= '<ul class="nav1st">';
foreach (OOCategory::getRootCategories() as $lev1) {
if ($lev1->isOnline(true)):
if ($lev1->getId() == $path1) {
$navLeftCol .= '<li id="cat_'.$lev1->getId().'" class="active"><a class="current" href="'.$lev1->getUrl().'">'.$lev1->getName().'</a>';
if ($lev1->getId() != "1") {
$sitePath .= ' ›› <a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a>';
}
$titlePath .= ' >> '.$lev1->getName();
}
// 1st level - no active link
else {
$navLeftCol .= '<li id="cat_'.$lev1->getId().'"><a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a>';
}
// 1st level had categories? -> go on
$lev1Size = sizeof($lev1->getChildren());
if ($lev1Size != "0"):
$navLeftCol .= '<ul class="nav2nd">';
// START 2nd level categories
foreach ($lev1->getChildren() as $lev2):
if ($lev2->isOnline()):
// 2nd level - active link
if ($lev2->getId() == $path2) {
$navLeftCol .= '<li class="active"><a class="current" href="'.$lev2->getUrl().'">'.$lev2->getName().'</a></li>';
$sitePath .= ' ›› <a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a>';
$titlePath .= ' >> '.$lev2->getName();
}
// 2nd level - no active link
else {
$navLeftCol .= '<li><a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a></li>';
}
endif;
endforeach;
// END 2nd level categories
$navLeftCol .= '</ul>';
endif; // END by if ($lev1Size != "0"):
$navLeftCol .= '</li>';
endif; // END by if ($lev1->isOnline())
}
$navLeftCol .= '</ul>';
// END 1st level categories
if ($REX['CUR_CLANG'] == 0) $breadcrumb = 'Sie sind hier: <a href="/index.php?clang=0">Start</a> '.$sitePath;
else $breadcrumb = '<a href="/cms/index.php">Start</a> '.$sitePath;
if ($REX['CUR_CLANG'] == 1) $breadcrumb = '<a href="/index.php?clang=1">Start</a> '.$sitePath;
else $breadcrumb = '<a href="/cms/index.php">Start</a> '.$sitePath;
if ($REX['CUR_CLANG'] == 2) $breadcrumb = '<a href="/index.php?clang=2">Start</a> '.$sitePath;
else $breadcrumb = '<a href="/cms/index.php">Start</a> '.$sitePath;
?>
Ist hoffentlich verständlich was ich meine. Besten Dank.
Gruss Kid