hier MEINE Version einer geteilten Navigation. Diese besteht aus zwei Modulen - Modul 1 gibt nur die erste Ebene der Hauptnavigation aus, Modul 2 gibt den Rest der Navigation in einem eigenen Container aus. In einer frühen Version gab es Probleme, falls man sich in einem anderen Navigationsbaum als der Hauptnavigation befand und diese Untermenüs hatte. Das Splitten und korrekte Ausgeben musste ich auf die Hauptnavigation einschränken. Daher wird im Modul 2 überprüft, ob man sich aktuell überhaupt in der Hauptnavigation befindet und wenn ja, auf welchem Level. Von dort aus wird bestimmt, in welcher Mutterkategorie innerhalb der Hauptkategorie man sich befindet, so dass von dort ausgehend jeweils die richtige Teilnavigation ausgegeben werden kann.
Hier Modul 1 (nur Output-Bereich):
Code: Alles auswählen
<?php
/**
* $RCSfile$
*
* Description:
* Main Navigation, displays Navigation from a starting idcat down to the max. level set.
* For now (as of 2009-01-12) all subcategories are put inside one <ul> and are assigned css classes
* to distinguish level depth, first/last and active item property.
*
* Module requires two client settings:
* navigation_main_standard | start_idcat
* navigation_main_standard | level_depth
*
* To modify the behaviour of the module (e.g. style of URL, CSS classes, ...), you need to edit Contenido_NavMain_Util::loopCats
* @see {frontend}/includes/Util/Modules/Contenido_NavMain_Util.class.php
*
* @version 1.0.0
* @author Rudi Bieller
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2009-01-12
* }}
*
* $Id: Navigation_Standard.php 3444 2009-01-19 11:42:59Z rudi.bieller $
*/
$actualid_partofmaintree = false;
if (!isset($db)) {
$db = new DB_Contenido();
}
if (!isset($tpl)) {
$tpl = new Template();
}
$tpl->reset();
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('frontend', 'includes/Util/Modules/Contenido_NavMain_Util.class.php');
$iStartIdcat = getEffectiveSetting('navigation', 'idcat-home', 1);
$iSelectedDepth = getEffectiveSetting('navigation', 'level-depth', 1);
if ($iStartIdcat > 0) {
$oFeNav = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$oFeNav->setAuth($auth);
$oFeNav->setRootCat($iStartIdcat);
$oSubCategories = $oFeNav->getSubCategories($iStartIdcat, true, true, 1);
// see if there are any subcategories to display
if ($oSubCategories->count() > 0) {
$aLevelInfo = array();
$aDepthInfo = array();
$aDepthInfo[0] = 0;
$aDepthInfo[1] = $iSelectedDepth;
foreach ($oSubCategories as $oSubCategory) {
Contenido_NavMain_Util::loopCats($oSubCategory, $oFeNav, $tpl, $cfg, $lang, $aLevelInfo, intval($idcat), $aDepthInfo);
}
$tpl->generate('templates/navigation_standard.html');
}
} else {
echo '<p>Navigation not configured correctly.</p>';
}
?>
Code: Alles auswählen
<?php
/**
* $RCSfile$
*
* Description:
* Main Navigation, displays Navigation from a starting idcat down to the max. level set.
* For now (as of 2009-01-12) all subcategories are put inside one <ul> and are assigned css classes
* to distinguish level depth, first/last and active item property.
*
* Module requires two client settings:
* navigation_main_standard | start_idcat
* navigation_main_standard | level_depth
*
* To modify the behaviour of the module (e.g. style of URL, CSS classes, ...), you need to edit Contenido_NavMain_Util::loopCats
* @see {frontend}/includes/Util/Modules/Contenido_NavMain_Util.class.php
*
* @version 1.0.0
* @author Rudi Bieller
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2009-01-12
* }}
*
* $Id: Navigation_Standard.php 3444 2009-01-19 11:42:59Z rudi.bieller $
*/
if (!isset($db)) {
$db = new DB_Contenido();
}
if (!isset($tpl)) {
$tpl = new Template();
}
$tpl->reset();
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('frontend', 'includes/Util/Modules/Contenido_NavMain_Util.class.php');
$iStartIdcat = getEffectiveSetting('navigation', 'idcat-home', 1);
$iSelectedDepth = getEffectiveSetting('navigation', 'level-depth', 1);
cInclude("classes", "class.category.php");
cInclude("classes", "class.cat.php");
$maincatid = $idcat;
$maincatid2 = $idcat;
// Vorgehen ist etwas verzwickt. Es gibt ein Problem, wenn die aktuelle Kategorie NICHT Teil des gewählten auszugebenden Navigationsbaumes ist.
// Die untenstehenden while-Schleife führt ins Nirvana und hängt das System auf.
// Daher muss zunächst überprüft werden, ob die aktuell angeklickte Kategorie Teil des auszugebenden Navigationsbaums ist - falls nein, muss die Sub-Schleife umgangen werden.
// Wir ermitteln das Level der aktuellen idcat und rechnen uns entsprechend viele Schritte hoch im Navibaum, um die Rootkategorie zu finden.
// Diese vergleichen wir mit der gewählten Startkategorie der Navigation - ist sie gleich, wird die das Submenü berechnet, sonst nicht.
// Rootkategorie ermitteln über das Level der aktuellen Kategorie
$oFeNav2 = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$idcatlevel = $oFeNav2->getLevel($idcat);
for ( $i=0; $i < $idcatlevel; $i++) {
$oActualCategory2 = new CategoryItem($maincatid2);
$maincatid2 = $oActualCategory2->get("parentid");
}
if ( $maincatid2 == $iStartIdcat ) {
while ( $maincatid != $iStartIdcat ) {
$iParentID = $maincatid; // bewahre den alten Wert, falls der neue die oberste Kategorie ist
$oActualCategory = new CategoryItem($maincatid);
$maincatid = $oActualCategory->get("parentid");
}
/* so lange schleifen, bis $maincatid == $iStartIdcat ist, dann war der Wert von $iParentID der korrekte, den also jeweils speichern */
/* Dann die zweite Ausgabe: */
if ($iParentID > 0) {
$oFeNav = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$oFeNav->setAuth($auth);
$oFeNav->setRootCat($iParentID);
$oSubCategories = $oFeNav->getSubCategories($iParentID, true, true, 1);
// see if there are any subcategories to display
if ($oSubCategories->count() > 0) {
$aLevelInfo = array();
$aDepthInfo = array();
$aDepthInfo[0] = 0;
$aDepthInfo[1] = $iSelectedDepth;
foreach ($oSubCategories as $oSubCategory) {
Contenido_NavMain_Util::loopCats($oSubCategory, $oFeNav, $tpl, $cfg, $lang, $aLevelInfo, intval($idcat), $aDepthInfo);
}
$tpl->generate('templates/navigation_sub.html');
}
} else {
echo '<p> </p>';
}
} // if actualid-ende
?>