Ich habe diese Navigation auf meiner Seite eingebaut (Redaxo v2.7) - nun will ich auf Version 3 umsteigen, nur wird folgende Fehlermeldung ausgegeben, sofern auf einer Unterseite die 2nd-Level-Navi ausgegeben werden soll:
Code: Alles auswählen
Fatal error: Call to a member function on a non-object in .../cmstest/redaxo/redaxo/include/generated/templates/9.template on line 13
Ich hoffe ihr könnt mir helfen - php ist absolut nicht meine Stärke.kills hat geschrieben:Top-Level-Navi:
2nd-Level-Navi:Code: Alles auswählen
<?php $path = explode("-",$this->getValue("path")); array_shift( $path); $cat_id = $path[0]; echo '<ul class="navi">'; foreach ( OOCategory::getRootCategories(true) as $oCategory) { $name = $oCategory->getName(); $url = $oCategory->getUrl(); $cid = $oCategory->getId(); $class = ''; if ( $cat_id == $cid) { $class = 'active'; } echo '<li class="'. $class .'"><a href="'. $url .'">'. $name .'</a></li>'; } echo '</ul>'; ?>
Side-Navi:Code: Alles auswählen
<?php $path = explode("-",$this->getValue("path")); array_shift( $path); $cat_id = $path[0]; $subcat_id = $path[1]; $oCurrCat = OOCategory::getCategoryById($cat_id); echo '<ul class="subnavi">'; foreach ( $oCurrCat->getChildren( true) as $oCategory) { $name = $oCategory->getName(); $url = $oCategory->getUrl(); $cid = $oCategory->getId(); $class = ''; if ( $subcat_id == $cid) { $class = 'active'; } echo '<li class="'. $class .'"><a href="'. $url .'">'. $name .'</a></li>'; } echo '</ul>'; ?>
Code: Alles auswählen
<?php $path = explode("-",$this->getValue("path")); array_shift( $path); $cat_id = $path[0]; $oCat = OOCategory::getCategoryById($cat_id); $Articles = $oCat->getArticles( true); if ( isset( $path[1])) { $subcat_id = $path[1]; $oSubCat = OOCategory::getCategoryById($subcat_id); $Articles = array_merge( $Articles, $oSubCat->getArticles( true)); } echo '<ul class="sidenavi">'; foreach ( $Articles as $oArticle) { $name = $oArticle->getName(); $url = $oArticle->getUrl(); $cid = $oArticle->getId(); $class = ''; if ( $subcat_id == $cid) { $class = 'active'; } echo '<li class="'. $class .'"><a href="'. $url .'">'. $name .'</a></li>'; } echo '</ul>'; ?>
Hier kann man die Struktur, so wie sie werden soll, anschauen.
Vielen Dank schon mal.
Liebe Grüße