Navigation: 4 statt 3 Ebenen

Wie verwendet man Templates oder erstellt Navigationen und passt diese an.

Navigation: 4 statt 3 Ebenen

Beitragvon rabby » 15. Aug 2007, 14:25

Hi,
momentan hab ich folgenden Code, der die Navigation erzeugt:

<?php
// EXPLODE PATH
$PATH = explode("|",$this->getValue("path").$this->getValue("article_id")."|");

// GET CURRENTS
$path1 = $PATH[1];
$path2 = $PATH[2];
$path3 = $PATH[3];
$path4 = $PATH[4];
$path5 = $PATH[5];

/* START 1st level categories */
$navHeader .= "\r\n".'<ul id="Navigation">'."\r\n";
$navLeftCol='';
foreach (OOCategory::getRootCategories() as $lev1) {
if ($lev1->isOnline()):
if ($lev1->getId() == $path1) {
$navHeader .= "\t".'<li class="active"><a class="current" href="'.$lev1->getUrl().'">'.$lev1->getName().'</a></li><!--deep_nav-->'."\r\n";
if ($lev1->getId() != "1") {
$sitePath .= ' ›› <a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a>';
}
$titlePath .= ' >> '.$lev1->getName();
}
// 2nd level - no active link
else {
$navHeader .= "\t".'<li><a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a></li>'."\r\n";
}
// 1st level had categories? -> go on
$lev1Size = sizeof($lev1->getChildren());
if ($lev1->getId() == $path1) {
if ($lev1Size != "0"):
$navLeftCol .= "\r\n"."\t"."<li id=\"nav2nd\"><!--fehler-->\r\n"."\t"."\t".'<ul>'."\r\n";

// START 2nd level categories
foreach ($lev1->getChildren() as $lev2):

if ($lev2->isOnline()):

// 2nd level - active link
if ($lev2->getId() == $path2) {

$navLeftCol .= "\r\n\t"."\t"."\t".'<li class="active"><a class="current" href="'.$lev2->getUrl().'">'.$lev2->getName().'</a>';
$sitePath .= ' ›› <a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a>';
$titlePath .= ' >> '.$lev2->getName();
}
// 2nd level - no active link
else {
$navLeftCol .= "\r\n\t"."\t"."\t".'<li><a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a></li>'."\r\n";
}

// 2st level had categories? -> go on
$lev2Size = sizeof($lev2->getChildren());

if ($lev2->getId() == $path2) {
if ($lev2Size != "0"):
$navLeftCol .= '</li>'."\r\n"."\t"."\t"."\t".'<li><ul class="nav3rd">'."\r\n";

// START 3nd level categories
foreach ($lev2->getChildren() as $lev3):

if ($lev3->isOnline()):

// 3nd level - active link
if ($lev3->getId() == $path3) {
$navLeftCol .= "\r\n\t"."\t"."\t"."\t".'<li class="active"><a class="current" href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
$sitePath .= ' ›› <a href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
$titlePath .= ' >> '.$lev3->getName();
}
// 3nd level - no active link
else {
$navLeftCol .= "\t"."\t"."\t"."\t".'<li><a href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
}

endif;
$navLeftCol .= '</li>'."\r\n";
endforeach;
$navLeftCol .= "\t"."\t"."\t".'</ul>'."\r\n";
// END 3nd level categories
endif;
$navLeftCol .= "\t"."\t\t".'</li>'."\r\n";
}
// END 2nd level categories
endif; // END by if ($lev1Size != "0"):
endforeach;
//$navHeader .= "\t".'</li>'."\r\n";
endif;
if ($navLeftCol != "") $navLeftCol .= "\t\t ".'</ul>'."\r\n"."\t"."</li>\r\n";
}
endif; // END by if ($lev1->isOnline())
}
$navHeader .= '</ul>'."\r\n";

// END 1st level categories

if ($REX['CUR_CLANG'] == 1) $breadcrumb = 'You are here: <a href="/index.php?clang=1">Startpage</a> '.$sitePath;
else $breadcrumb = 'Sie sind hier: <a href="/index.php">Startseite</a> '.$sitePath;
?>


Doch nun würde ich gerne noch eine 4. Ebenenstufe dazuhaben.
Habe einiges probiert; kam aber nicht auf den richtigen Code.

Schönen tlw. Feiertag noch.
rabby
 
Beiträge: 25
Registriert: 28. Okt 2006, 16:42

Beitragvon n.ruediger » 17. Aug 2007, 20:28

Hallo,

versuch mal das hier:

Code: Alles auswählen
<?php
  // EXPLODE PATH
  $PATH = explode("|",$this->getValue("path").$this->getValue("article_id")."|");

  // GET CURRENTS
  $path1 = $PATH[1];
  $path2 = $PATH[2];
  $path3 = $PATH[3];
  $path4 = $PATH[4];
  $path5 = $PATH[5];

  /* START 1st level categories */
  $navHeader .= "\r\n".'<ul id="Navigation">'."\r\n";
  $navLeftCol='';

  foreach (OOCategory::getRootCategories() as $lev1) {
    if ($lev1->isOnline()) {         
      // 1nd level - active link
      if ($lev1->getId() == $path1) {
        $navHeader .= "\t".'<li class="active"><a class="current" href="'.$lev1->getUrl().'">'.$lev1->getName().'</a></li><!--deep_nav-->'."\r\n";
        if ($lev1->getId() != "1") {
          $sitePath .= ' ›› <a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a>';
        }
        $titlePath .= ' >> '.$lev1->getName();
      }
      // 1nd level - no active link
      else {
        $navHeader .= "\t".'<li><a href="'.$lev1->getUrl().'">'.$lev1->getName().'</a></li>'."\r\n";
      }

      // 1st level had categories? -> go on
      $lev1Size = sizeof($lev1->getChildren());
      if ($lev1->getId() == $path1) {
        if ($lev1Size != "0") {
          $navLeftCol .= "\r\n"."\t"."<li id=\"nav2nd\"><!--fehler-->\r\n"."\t"."\t".'<ul>'."\r\n";

          // START 2nd level categories
          foreach ($lev1->getChildren() as $lev2) {
            if ($lev2->isOnline()) {
              // 2nd level - active link
              if ($lev2->getId() == $path2) {
                $navLeftCol .= "\r\n\t"."\t"."\t".'<li class="active"><a class="current" href="'.$lev2->getUrl().'">'.$lev2->getName().'</a>';
                $sitePath .= ' ›› <a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a>';
                $titlePath .= ' >> '.$lev2->getName();
              }
              // 2nd level - no active link
              else {
                $navLeftCol .= "\r\n\t"."\t"."\t".'<li><a href="'.$lev2->getUrl().'">'.$lev2->getName().'</a></li>'."\r\n";
              }

              // 2st level had categories? -> go on
              $lev2Size = sizeof($lev2->getChildren());
              if ($lev2->getId() == $path2) {
                if ($lev2Size != "0") {
                  $navLeftCol .= '</li>'."\r\n"."\t"."\t"."\t".'<li><ul class="nav3rd">'."\r\n";

                  // START 3nd level categories
                  foreach ($lev2->getChildren() as $lev3) {
                    if ($lev3->isOnline()) {
                      // 3nd level - active link
                      if ($lev3->getId() == $path3) {
                        $navLeftCol .= "\r\n\t"."\t"."\t"."\t".'<li class="active"><a class="current" href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
                        $sitePath .= ' ›› <a href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
                        $titlePath .= ' >> '.$lev3->getName(); 
                       
                        $lev3Size = sizeof($lev3->getChildren());
                        if ($lev3->getId() == $path3) {
                          if ($lev3Size != "0") {                                               
                            $navLeftCol .= '</li>'."\r\n"."\t"."\t"."\t".'<li><ul class="nav3rd">'."\r\n";
                           
                            // START 4th level categories
                            foreach ($lev3->getChildren() as $lev4) {
                              if ($lev4->isOnline()) {
                                // 4nd level - active link
                                if ($lev4->getId() == $path4) {
                                  $navLeftCol .= "\r\n\t"."\t"."\t"."\t".'<li class="active"><a class="current" href="'.$lev4->getUrl().'">'.$lev4->getName().'</a>';
                                  $sitePath .= ' ›› <a href="'.$lev4->getUrl().'">'.$lev4->getName().'</a>';
                                  $titlePath .= ' >> '.$lev4->getName(); 
                                }
                                // 4nd level - no active link
                                else {
                                  $navLeftCol .= "\t"."\t"."\t"."\t".'<li><a href="'.$lev4->getUrl().'">'.$lev4->getName().'</a>';
                                }                                                                                                     
                              }
                            }
                          }
                        }
                      }
                      // 3nd level - no active link
                      else {
                        $navLeftCol .= "\t"."\t"."\t"."\t".'<li><a href="'.$lev3->getUrl().'">'.$lev3->getName().'</a>';
                      }
                    }
                    $navLeftCol .= '</li>'."\r\n";
                  }
                  $navLeftCol .= "\t"."\t"."\t".'</ul>'."\r\n";
                  // END 3nd level categories
                }
                $navLeftCol .= "\t"."\t\t".'</li>'."\r\n";
              }
              // END 2nd level categories
            }
          }
          //$navHeader .= "\t".'</li>'."\r\n";
        }
        if ($navLeftCol != "") $navLeftCol .= "\t\t ".'</ul>'."\r\n"."\t"."</li>\r\n";
      }
    }
  }
  $navHeader .= '</ul>'."\r\n";
  // END 1st level categories

  if ($REX['CUR_CLANG'] == 1) $breadcrumb = 'You are here: <a href="/index.php?clang=1">Startpage</a> '.$sitePath;
  else $breadcrumb = 'Sie sind hier: <a href="/index.php">Startseite</a> '.$sitePath;
?>


Liebe Grüße,
Nicole
Benutzeravatar
n.ruediger
 
Beiträge: 418
Registriert: 21. Mär 2007, 11:25
Wohnort: Frankfurt (Oder)


Zurück zu Templates/Navigationen [R3]

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast