Seite 1 von 2
Unterscheidliche Bilder in Navigation einbinden
Verfasst: Do 18. Dez 2008, 11:48
von peter_lang
Hallo,
ich möchte gerne unterscheidliche Bidler/icons vor jeden Navigationspunkt setzen .. da die Navi aber dynamisch generiert wird stehe ich etwas auf dem Schlauch ..
Hier ein Bild, was ich meine
Hat einer Rat?
Verfasst: Do 18. Dez 2008, 13:39
von Dalamar
Würde mich auch interessieren... ich habe das bisher immer so gelöst, dass ich die Bilder genau wie die Kategorie benannt habe, bzw. die idcat für den Bildnamen benutzt habe.
Christian
Verfasst: Do 18. Dez 2008, 13:40
von funomat
Geht es Dir nur darum, wie Du es im Navigationsmodul umsetzt, oder auch wie das CSS aussehen muss?
Verfasst: Do 18. Dez 2008, 14:14
von funomat
Also, ich habe das jetzt mal mit Farben anstatt mit Bildern gelöst:
Beispiel
Hier der Code:
navigation_main_item.html
Code: Alles auswählen
<!-- BEGIN:BLOCK -->
<li{css-class}><a{css-id} href="{url}" title="{title}">{label}</a>{subcategories}</li>
<!-- END:BLOCK -->
Modul output Navigation_Main
Code: Alles auswählen
<?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, 1); // 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) {
$i = 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;
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 = '';
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"' : ''), '', 0);
}
$sSubcats2 = $tpl3->generate('templates/navigation_main_item.html', true, false);
$tpl3->reset();
$tpl3->set('s', 'items', $sSubcats2);
$tpl3->set('s', 'css-class', ' class="subSubNavigation"');
$sSubcats2 = $tpl3->generate('templates/navigation_main_container.html', true, false);
}
if ($bHasActiveSubCat === false && intval($idcat) == $oSubCategory->getIdCat()) {
$bHasActiveSubCat = true;
}
toTpl($tpl2, $oSubCategory,
(intval($idcat) == $oSubCategory->getIdCat() || $bHasActiveSubSubCat === true ? ' class="active"' : ''),
$sSubcats2, 0);
}
$sSubcats = $tpl2->generate('templates/navigation_main_item.html', true, false);
$tpl2->reset();
$tpl2->set('s', 'items', $sSubcats);
$tpl2->set('s', 'css-class', ' class="subNavigation"');
$sSubcats = $tpl2->generate('templates/navigation_main_container.html', true, false);
}
$i++;
toTpl($tpl, $oContenidoCategory, ($bHasActiveSubCat === true || intval($idcat) == $oContenidoCategory->getIdCat() ? ' class="active"' : ''), $sSubcats, $i);
}
$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, $i) {
$oTpl->set('d', 'css-class', $sActiveCssClass);
if ($i!=0)
$oTpl->set('d', 'css-id', ' id="nav_'.$i.'"');
else
$oTpl->set('d', 'css-id', '');
$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();
}
?>
CSS
Code: Alles auswählen
#navigation #nav_1 { border-left: 10px solid #ff90d2; }
#navigation #nav_2 { border-left: 10px solid #ff9090; }
#navigation #nav_3 { border-left: 10px solid #ffbc90; }
#navigation #nav_4 { border-left: 10px solid #ffe590; }
#navigation #nav_5 { border-left: 10px solid #f0ff90; }
#navigation #nav_6 { border-left: 10px solid #baff90; }
Der CSS-Code ist nur ein Vorschlag. Man kann natürlich im Template die {css-id} dem li-Tag zuweisen und entsprechend die CSS-Anweisungen der Navigation so anpassen, dass es trotzdem noch genau so aussieht aber bei den Unternavigationspunkten die Farbe mit übernommen wird.
Das ist aber Geschmackssache!
Gruß,
funomat
Verfasst: Do 18. Dez 2008, 14:45
von peter_lang
GEIL .. das ist es .. super .. vielen Dank.
Verfasst: Do 18. Dez 2008, 14:51
von funomat
Gerne doch

Verfasst: Do 18. Dez 2008, 15:50
von peter_lang
mal ne andere Frage, wie kann man denn den Pfadfrimmel hinter der Domain ausschalten .. falls es geht
www.xxx.de/cms/front_content.php?idcat=12
dass z.b. nur die kategorien hinter der domain angezeigt werden
www.xxx.de/ueber-uns/
Verfasst: Do 18. Dez 2008, 15:55
von funomat
Für alle Versionen ab 4.8.x nimmst Du das am besten:
http://forum.contenido.org/viewtopic.php?t=21578
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 12:52
von Stephan73
Hallo zusammen!
Ich habe die Navigation von Funomat eingebunden.
Leider klappt es nicht.
Auf der Webseite kommt nur die Meldung "templates/Navigation_main_container.html".
Gemacht habe ich:
- Modul-Template navigation_main_item.html erstellt
- Modul Navigation_main abgeändert
- css ergänzt.
Wäre dankbar für Hilfe!
Gruß,
Stephan
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 12:55
von idea-tec
poste mal das geänderte Modul und, falls es nicht ein Original ist, auch das modul-template
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 12:58
von Stephan73
Gerne!
Modul: Navigation_Main
Code: Alles auswählen
<?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, 1); // 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) {
$i = 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;
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 = '';
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"' : ''), '', 0);
}
$sSubcats2 = $tpl3->generate('templates/navigation_main_item.html', true, false);
$tpl3->reset();
$tpl3->set('s', 'items', $sSubcats2);
$tpl3->set('s', 'css-class', ' class="subSubNavigation"');
$sSubcats2 = $tpl3->generate('templates/navigation_main_container.html', true, false);
}
if ($bHasActiveSubCat === false && intval($idcat) == $oSubCategory->getIdCat()) {
$bHasActiveSubCat = true;
}
toTpl($tpl2, $oSubCategory,
(intval($idcat) == $oSubCategory->getIdCat() || $bHasActiveSubSubCat === true ? ' class="active"' : ''),
$sSubcats2, 0);
}
$sSubcats = $tpl2->generate('templates/navigation_main_item.html', true, false);
$tpl2->reset();
$tpl2->set('s', 'items', $sSubcats);
$tpl2->set('s', 'css-class', ' class="subNavigation"');
$sSubcats = $tpl2->generate('templates/navigation_main_container.html', true, false);
}
$i++;
toTpl($tpl, $oContenidoCategory, ($bHasActiveSubCat === true || intval($idcat) == $oContenidoCategory->getIdCat() ? ' class="active"' : ''), $sSubcats, $i);
}
$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, $i) {
$oTpl->set('d', 'css-class', $sActiveCssClass);
if ($i!=0)
$oTpl->set('d', 'css-id', ' id="nav_'.$i.'"');
else
$oTpl->set('d', 'css-id', '');
$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();
}
?>
Modul-Template: navigation_main_item.html
Code: Alles auswählen
<!-- BEGIN:BLOCK -->
<li{css-class}><a{css-id} href="{url}" title="{title}">{label}</a>{subcategories}</li>
<!-- END:BLOCK -->
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 13:08
von idea-tec
So, dann noch als erstes eine Schulung zur Forumsnutzung:
man benutzt den Button "Code", wenn man programmierung postet.
hierzu wie erwähnt auf "Code" klicken, oberhalb des Eingabefeldes
Nun erscheint im Textarea, hier unten in dem ich auch gerade schreibe, folgendes:
[/code]ZWISCHEN die beiden Zeichen "]" und "[" die direkt nebeneinander liegen fügst du nun deinen zu postenden Code ein und schreibst dann HINTER oder außerhalb des Code-Tags weiter.
Dann sieht dein geposteter Code so aus, wie das beispiel in diesem Post hier, das mit "Code: ALLLES AUSWÄHLEN" und dem weißen Hintergrund
Gehe also bitte in deinen Post und füge, zumindest um den Modul-Code den entsprechenden Code-Tag ein. am einfachsten fügst du direkt VOR <?php und direkt HINTER ?> einfach die entsprechenden tags von hand ein, danke!
ich würde es ja selbst tun, aber ich habe nicht die notwendigen rechte hier im forum.
gruß, karsten
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 13:10
von funomat
Hast Du denn das Template navigation_main_container.html?

Und bitte nächstes mal dem Quellcode auch als solchen in Deinen Thread einbinden (Button "Code" oder [ code ] Quellcode... [ / code ])
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 13:13
von idea-tec
ja, da war ich auch gerade am vergleichen, und da nur ein template hier gepostet ist, gehe ich schwer davon aus, dass ihm das andere fehlt.
gruß, karsten
Re: Unterscheidliche Bilder in Navigation einbinden
Verfasst: Di 7. Apr 2009, 13:25
von Stephan73
Sorry! Jetzt habe ich den Code "codiert"!
Ich habe jetzt ein Modul-Template navigation_main_container.html angelegt.
Was muss da für Code hinein?
Code: Alles auswählen
<!-- BEGIN:BLOCK -->
<li{css-class}><a{css-id} href="{url}" title="{title}">{label}</a>{subcategories}</li>
<!-- END:BLOCK -->
... ergibt keine Ausgabe im Browser.