Hallo,
hat jemand von euch ein Modul für eine horizontale Navigation mit 4 oder 5 Ebenen?
Haupt
Unter1
Unter2
Unter3
Unter4
Gruß sarron
Horizontale Navgation 4.8
-
- Beiträge: 251
- Registriert: Do 10. Mär 2011, 17:02
- Wohnort: Erlangen
- Kontaktdaten:
Re: Horizontale Navgation 4.8
Hallo,
ich meine, dass dir das folgende einen Kategoriebaum bis in die unterste Ebene gesamt ausgeben müsste, wenn du die Variable $hauptkategorie noch anpasst auf die idcat:
Der Rest ist dann eine Frage von CSS und/oder Jquery, um das zu steuern und zu animieren, das hat nix wirklich mit Contenido zu tun, da schau dich mal weiter um.
Ich kopiere dir mal aus einem Projekt die css-Fetzen rein, die ich gefunden habe, was aber nicht heißt, dass die vollständig sind. Außerdem wirken die mit Sicherheit erstmal nur bis in die zweite Ebene:
LG
ich meine, dass dir das folgende einen Kategoriebaum bis in die unterste Ebene gesamt ausgeben müsste, wenn du die Variable $hauptkategorie noch anpasst auf die idcat:
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : vpNavigation 0.2
* Author : Ingo van Peeren
* Copyright : Ingo van Peeren (ingo@van-peeren.de)
* Created : 30-03-2005
* Modified : 16-07-2005
************************************************/
//$hauptkategorie = "CMS_VALUE[0]";
$hauptkategorie = "75";
$navitems = array();
function nav_feld ($cat) {
global $client, $lang, $cfg, $idcat;
if (!is_object($db)) {
$db = new DB_Contenido;
}
$sql = "SELECT
A.idcat,
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
B.parentid = '$cat'
ORDER BY
A.idtree";
$db->query($sql);
while ( $db->next_record() ) {
$aktiv = "";
$sub_feld = nav_feld($db->f("idcat"));
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 = " ")
{
global $first;
if (is_array($array["feld"])) {
if ($first) {
echo $indent . "<ul id=\"nav\">\n";
$first = 0;
}
else echo $indent . "<ul>\n";
foreach ($array["feld"] as $menupunkt) {
if ($menupunkt["active"] == "active") echo $indent . $indent . "<li id=\"active\">\n";
elseif ($menupunkt["active"] == "activepath") echo $indent . $indent . "<li class=\"activepath\">\n";
else echo $indent . $indent . "<li>\n";
if (is_array($menupunkt["sub"]["feld"])) {
echo $indent . $indent . $indent . "<a class=\"daddy\" href=\"front_content.php?idcat=" . $menupunkt["idcat"] . "\">" . $menupunkt["name"] . "</a>\n";
liste($menupunkt["sub"], $indent." ");
}
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";
}
}
/* Create Navigation Array */
$navitems = nav_feld($hauptkategorie);
$first = 1;
liste($navitems);
?>
Ich kopiere dir mal aus einem Projekt die css-Fetzen rein, die ich gefunden habe, was aber nicht heißt, dass die vollständig sind. Außerdem wirken die mit Sicherheit erstmal nur bis in die zweite Ebene:
Code: Alles auswählen
/* Horizontale Navigation */
#vpnavigation {
position: absolute;
top: 83px;
}
#vpnavigation, #vpnavigation ul { /* alle Listen */
padding: 0;
margin: 0;
list-style: none;
line-height: 1;
}
#vpnavigation a {
display: block;
color: white;
font-size: 16px;
font-weight: bold;
text-indent: 10px;
}
#vpnavigation a:hover { color: #99AFD1;}
#vpnavigation li { /* alle Listenelemente */
float: left;
width: 150px;
height: 28px;
line-height: 28px;
background-image: url(../images/nav1_background.jpg);
background-repeat: no-repeat;
}
#vpnavigation li#active, #vpnavigation li.activepath { /* Listen zur aktuellen Kategorie */
font-style: normal!important;
background-image: url(../images/nav1_active.jpg);
background-repeat: no-repeat;
}
#vpnavigation li#active a:hover { color: white;}
#vpnavigation li#active li a:hover { color: #99AFD1;}
#vpnavigation li ul { /* Listen 2. Ebene */
position: absolute;
width: 150px;
background-image: url(../images/nav12_trenner.jpg);
background-repeat: repeat;
left: -999em; /* durch "left" außerhalb des sichtbaren Bereichs wird das gleiche erreicht wie durch "display: none", kann aber auch von Textbrowser angezeigt werden */
}
#vpnavigation li li a {
color: white;
font-size: 11px;
font-weight: normal;
text-indent: 10px;
}
#vpnavigation li li { /* Listen 2. Ebene */
background-image: url(../images/nav12_background.jpg);
background-repeat: repeat;
margin-bottom: 2px;
width: 150px;
height: 16px;
line-height: 16px;
}
#vpnavigation li li#active {
background-image: url(../images/nav1_active.jpg);
background-repeat: repeat-y;
}
#vpnavigation li li a.daddy { /* Listenelemente mit Unterpunkten */
}
#vpnavigation li ul ul { /* Listen 3. Ebene und weiter */
margin: -1em 0 0 10em;
}
#vpnavigation li:hover ul ul, #vpnavigation li.sfhover ul ul {
left: -999em;
}
#vpnavigation li:hover ul, #vpnavigation li li:hover ul, #vpnavigation li.sfhover ul, #vpnavigation li li.sfhover ul { /* Listen, die unterhalb von "gehoverten" Menüpunkte liegen */
left: auto;
}
-
- Beiträge: 251
- Registriert: Do 10. Mär 2011, 17:02
- Wohnort: Erlangen
- Kontaktdaten:
Re: Horizontale Navgation 4.8
Danke für die Info.
Werds mir morgen mal in Ruhe ansehen.
Gruß sarron
Werds mir morgen mal in Ruhe ansehen.
Gruß sarron
-
- Beiträge: 251
- Registriert: Do 10. Mär 2011, 17:02
- Wohnort: Erlangen
- Kontaktdaten:
Re: Horizontale Navgation 4.8
In der Version 8.8 gab es ein horizontales Nagigationsmenü welches 3 Stufen auflöst.
Ich brauche jetzt noch eine Stufe mehr weiß aber nicht wie ich den Code dazu ändern kann.
Kann mir da jemand helfen.
Navigationsmodul aus 4.8:
-------------------------------
<?php
/**
* $RCSfile$
*
* Description: Navigation, left side.
*
* @version 1.0.0
* @author Rudi Bieller
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2008-04-07
* }}
*
* $Id$
*/
// include Contenido_FrontendNavigation class
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation_Breadcrumb.class.php');
// get start idcat
$iIdcatStart = getEffectiveSetting('navigation', 'idcat-home', 1);
// instantiate 2nd + 3rd template object, reset all
$tpl2 = new Template();
$tpl3 = new Template();
if (!isset($tpl) || !is_object($tpl)) {
$tpl = new Template();
}
$tpl->reset();
$tpl2->reset();
$tpl3->reset();
// build navigation
try {
$oFeNav = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$oBreadcrumb = new Contenido_FrontendNavigation_Breadcrumb($db, $cfg, $client, $lang, $cfgClient);
$aBreadcrumb = $oBreadcrumb->getAsArray($idcat, 0); // this nav starts at level 1
$oFeNav->setAuth($auth); // to make sure user sees what he's allowed to see
$oContenidoCategories = $oFeNav->getSubCategories($iIdcatStart, true);
if ($oContenidoCategories->count() > 0) {
foreach ($oContenidoCategories as $oContenidoCategory) {
$sSubcats = '';
$tpl2->reset();
$bHasActiveSubCat = false;
// check if we need to load subcategories
$oSubCatsLevel2 = $oFeNav->getSubCategories($oContenidoCategory->getIdCat(), true);
$aSubCatsLevel2 = $oFeNav->getSubCategories($oContenidoCategory->getIdCat(), false);
$bShowSubcatLevel2 = (intval($idcat) == $oContenidoCategory->getIdCat() || in_array(intval($idcat), $aSubCatsLevel2)
|| (isset($aBreadcrumb[2]) && intval($idcat) == $aBreadcrumb[2] && in_array($aBreadcrumb[1], $aSubCatsLevel2)))
? true : false;
$bShowSubcatLevel2 = true;
if ($bShowSubcatLevel2 === true && $oSubCatsLevel2->count() > 0) {
foreach ($oFeNav->getSubCategories($oContenidoCategory->getIdCat(), true) as $oSubCategory) {
$bHasActiveSubSubCat = false;
// check if we need to load subsubcategories
$oSubCatsLevel3 = $oFeNav->getSubCategories($oSubCategory->getIdCat(), true);
$aSubCatsLevel3 = $oFeNav->getSubCategories($oSubCategory->getIdCat(), false);
$bShowSubcatLevel3 = (intval($idcat) == $oSubCategory->getIdCat() ||
in_array(intval($idcat), $aSubCatsLevel3))
? true : false;
$sSubcats2 = '';
$bShowSubcatLevel3 = true;
if ($bShowSubcatLevel3 === true && $oSubCatsLevel3->count() > 0) {
foreach ($oSubCatsLevel3 as $oSubSubCategories) {
if ($bHasActiveSubCat === false && intval($idcat) == $oSubSubCategories->getIdCat()) {
$bHasActiveSubCat = true;
}
if ($bHasActiveSubSubCat === false && intval($idcat) == $oSubSubCategories->getIdCat()) {
$bHasActiveSubSubCat = true;
}
toTpl($tpl3, $oSubSubCategories, (intval($idcat) == $oSubSubCategories->getIdCat() ? ' class="active"' : ''), '');
}
$sSubcats2 = $tpl3->generate('templates/navigation_main_item.html', true, false);
$tpl3->reset();
$tpl3->set('s', 'items', $sSubcats2);
$tpl3->set('s', 'css-class', ' class="sub-menuxx"');
$sSubcats2 = $tpl3->generate('templates/navigation_main_container_under.html', true, false);
}
if ($bHasActiveSubCat === false && intval($idcat) == $oSubCategory->getIdCat()) {
$bHasActiveSubCat = true;
}
toTpl($tpl2, $oSubCategory,
(intval($idcat) == $oSubCategory->getIdCat() || $bHasActiveSubSubCat === true ? ' class="active"' : ''),
$sSubcats2);
}
$sSubcats = $tpl2->generate('templates/navigation_main_item.html', true, false);
$tpl2->reset();
$tpl2->set('s', 'items', $sSubcats);
$tpl2->set('s', 'css-class', ' class="sub-menu"');
$sSubcats = $tpl2->generate('templates/navigation_main_container_under.html', true, false);
}
toTpl($tpl, $oContenidoCategory, ($bHasActiveSubCat === true || intval($idcat) == $oContenidoCategory->getIdCat() ? ' class="active"' : ''), $sSubcats);
}
$sCats = $tpl->generate('templates/navigation_main_item.html', true, false);
$tpl->reset();
$tpl->set('s', 'css-class', '');
$tpl->set('s', 'items', $sCats);
$tpl->generate('templates/navigation_main_container.html');
}
} catch (Exception $e) {
echo 'Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line '.$e->getLine() . ' ('.$e->getTraceAsString().')';
}
/**
* Helper to push values to Template object
* @param Template $oTpl
* @param Contenido_Category $oCat
* @param string $sActiveCssClass must bei either empty string or " class="classname"
* @param string $sSubcats String with subcategories of current category
*/
function toTpl(&$oTpl, Contenido_Category $oCat, $sActiveCssClass, $sSubcats) {
$pos = strpos($sActiveCssClass,"active");
if ($pos) {
$sActiveCssClass = " class='sub-menu active'";
} else {
$sActiveCssClass = " class='sub-menu'";
}
$oTpl->set('d', 'css-class', $sActiveCssClass);
$oTpl->set('d', 'url', 'front_content.php?idcat='.$oCat->getIdCat());
$oTpl->set('d', 'title', $oCat->getCategoryLanguage()->getName());
$oTpl->set('d', 'label', $oCat->getCategoryLanguage()->getName());
$oTpl->set('d', 'subcategories', $sSubcats); // followup level
$oTpl->next();
}
?>
Gruß sarron
Ich brauche jetzt noch eine Stufe mehr weiß aber nicht wie ich den Code dazu ändern kann.
Kann mir da jemand helfen.
Navigationsmodul aus 4.8:
-------------------------------
<?php
/**
* $RCSfile$
*
* Description: Navigation, left side.
*
* @version 1.0.0
* @author Rudi Bieller
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2008-04-07
* }}
*
* $Id$
*/
// include Contenido_FrontendNavigation class
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation_Breadcrumb.class.php');
// get start idcat
$iIdcatStart = getEffectiveSetting('navigation', 'idcat-home', 1);
// instantiate 2nd + 3rd template object, reset all
$tpl2 = new Template();
$tpl3 = new Template();
if (!isset($tpl) || !is_object($tpl)) {
$tpl = new Template();
}
$tpl->reset();
$tpl2->reset();
$tpl3->reset();
// build navigation
try {
$oFeNav = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$oBreadcrumb = new Contenido_FrontendNavigation_Breadcrumb($db, $cfg, $client, $lang, $cfgClient);
$aBreadcrumb = $oBreadcrumb->getAsArray($idcat, 0); // this nav starts at level 1
$oFeNav->setAuth($auth); // to make sure user sees what he's allowed to see
$oContenidoCategories = $oFeNav->getSubCategories($iIdcatStart, true);
if ($oContenidoCategories->count() > 0) {
foreach ($oContenidoCategories as $oContenidoCategory) {
$sSubcats = '';
$tpl2->reset();
$bHasActiveSubCat = false;
// check if we need to load subcategories
$oSubCatsLevel2 = $oFeNav->getSubCategories($oContenidoCategory->getIdCat(), true);
$aSubCatsLevel2 = $oFeNav->getSubCategories($oContenidoCategory->getIdCat(), false);
$bShowSubcatLevel2 = (intval($idcat) == $oContenidoCategory->getIdCat() || in_array(intval($idcat), $aSubCatsLevel2)
|| (isset($aBreadcrumb[2]) && intval($idcat) == $aBreadcrumb[2] && in_array($aBreadcrumb[1], $aSubCatsLevel2)))
? true : false;
$bShowSubcatLevel2 = true;
if ($bShowSubcatLevel2 === true && $oSubCatsLevel2->count() > 0) {
foreach ($oFeNav->getSubCategories($oContenidoCategory->getIdCat(), true) as $oSubCategory) {
$bHasActiveSubSubCat = false;
// check if we need to load subsubcategories
$oSubCatsLevel3 = $oFeNav->getSubCategories($oSubCategory->getIdCat(), true);
$aSubCatsLevel3 = $oFeNav->getSubCategories($oSubCategory->getIdCat(), false);
$bShowSubcatLevel3 = (intval($idcat) == $oSubCategory->getIdCat() ||
in_array(intval($idcat), $aSubCatsLevel3))
? true : false;
$sSubcats2 = '';
$bShowSubcatLevel3 = true;
if ($bShowSubcatLevel3 === true && $oSubCatsLevel3->count() > 0) {
foreach ($oSubCatsLevel3 as $oSubSubCategories) {
if ($bHasActiveSubCat === false && intval($idcat) == $oSubSubCategories->getIdCat()) {
$bHasActiveSubCat = true;
}
if ($bHasActiveSubSubCat === false && intval($idcat) == $oSubSubCategories->getIdCat()) {
$bHasActiveSubSubCat = true;
}
toTpl($tpl3, $oSubSubCategories, (intval($idcat) == $oSubSubCategories->getIdCat() ? ' class="active"' : ''), '');
}
$sSubcats2 = $tpl3->generate('templates/navigation_main_item.html', true, false);
$tpl3->reset();
$tpl3->set('s', 'items', $sSubcats2);
$tpl3->set('s', 'css-class', ' class="sub-menuxx"');
$sSubcats2 = $tpl3->generate('templates/navigation_main_container_under.html', true, false);
}
if ($bHasActiveSubCat === false && intval($idcat) == $oSubCategory->getIdCat()) {
$bHasActiveSubCat = true;
}
toTpl($tpl2, $oSubCategory,
(intval($idcat) == $oSubCategory->getIdCat() || $bHasActiveSubSubCat === true ? ' class="active"' : ''),
$sSubcats2);
}
$sSubcats = $tpl2->generate('templates/navigation_main_item.html', true, false);
$tpl2->reset();
$tpl2->set('s', 'items', $sSubcats);
$tpl2->set('s', 'css-class', ' class="sub-menu"');
$sSubcats = $tpl2->generate('templates/navigation_main_container_under.html', true, false);
}
toTpl($tpl, $oContenidoCategory, ($bHasActiveSubCat === true || intval($idcat) == $oContenidoCategory->getIdCat() ? ' class="active"' : ''), $sSubcats);
}
$sCats = $tpl->generate('templates/navigation_main_item.html', true, false);
$tpl->reset();
$tpl->set('s', 'css-class', '');
$tpl->set('s', 'items', $sCats);
$tpl->generate('templates/navigation_main_container.html');
}
} catch (Exception $e) {
echo 'Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line '.$e->getLine() . ' ('.$e->getTraceAsString().')';
}
/**
* Helper to push values to Template object
* @param Template $oTpl
* @param Contenido_Category $oCat
* @param string $sActiveCssClass must bei either empty string or " class="classname"
* @param string $sSubcats String with subcategories of current category
*/
function toTpl(&$oTpl, Contenido_Category $oCat, $sActiveCssClass, $sSubcats) {
$pos = strpos($sActiveCssClass,"active");
if ($pos) {
$sActiveCssClass = " class='sub-menu active'";
} else {
$sActiveCssClass = " class='sub-menu'";
}
$oTpl->set('d', 'css-class', $sActiveCssClass);
$oTpl->set('d', 'url', 'front_content.php?idcat='.$oCat->getIdCat());
$oTpl->set('d', 'title', $oCat->getCategoryLanguage()->getName());
$oTpl->set('d', 'label', $oCat->getCategoryLanguage()->getName());
$oTpl->set('d', 'subcategories', $sSubcats); // followup level
$oTpl->next();
}
?>
Gruß sarron
-
- Beiträge: 4255
- Registriert: Do 30. Jun 2005, 22:56
- Wohnort: Eltmann, Unterfranken, Bayern
- Kontaktdaten:
Re: Horizontale Navgation 4.8
Servus,
ach ja, das alte "Schachtelhalm"-Modul.
Um eine 4. Ebene zu erhalten müsstest Du den Bereich der 3. Ebene im Modul kopieren, alle Bezüge zu dieser 3. Ebene in 4. Ebene ändern und, analog zum Einbau der 3. Ebene in die 2. Ebene, die 4. Ebene in die 3. Ebene einbauen. Eine Instanz der Template-Klasse für Ebene 4 und ein entsprechendes Template kämen dann noch dazu und fertig.
Gruß aus Franken
Ortwin
ach ja, das alte "Schachtelhalm"-Modul.
Um eine 4. Ebene zu erhalten müsstest Du den Bereich der 3. Ebene im Modul kopieren, alle Bezüge zu dieser 3. Ebene in 4. Ebene ändern und, analog zum Einbau der 3. Ebene in die 2. Ebene, die 4. Ebene in die 3. Ebene einbauen. Eine Instanz der Template-Klasse für Ebene 4 und ein entsprechendes Template kämen dann noch dazu und fertig.
Gruß aus Franken
Ortwin
ConLite 2.1, alternatives und stabiles Update von Contenido 4.8.x unter PHP 7.x - Download und Repo auf Gitport.de
phpBO Search Advanced - das Suchwort-Plugin für CONTENIDO 4.9
Mein Entwickler-Blog
phpBO Search Advanced - das Suchwort-Plugin für CONTENIDO 4.9
Mein Entwickler-Blog
-
- Beiträge: 251
- Registriert: Do 10. Mär 2011, 17:02
- Wohnort: Erlangen
- Kontaktdaten:
Re: Horizontale Navgation 4.8
Hallo hintäte,
Danke für dein Modul. Es funktioniert perfekt.. Ein paar kleine Anpassungen bei den Tags und es passt. So einwandfrei für mich..
Gruß sarron
Danke für dein Modul. Es funktioniert perfekt.. Ein paar kleine Anpassungen bei den Tags und es passt. So einwandfrei für mich..
Gruß sarron