Erzeugt wird eine W3C Konforme Subnavigation
Grundaufbau der Kategorien in Contenido sieht bei mir folgendermaßen aus und damit funzt das ohne Probleme und wunderbest:
_Hauptnavigation
__Kategorie 1
___Unterkategorie 1.1
___Unterkategorie 1.2
__Kategorie 2
___Unterkategorie 2.1
___Unterkategorie 2.2
Programmiert werden kann das ganze 100%ig noch schöner und da würde ich mich über Kritik sehr freuen

webtischlerei.class.php
Code: Alles auswählen
<?php
/****************************************************************
* CONTENIDO CLASS - webtischlerei.de
*
* Version : 0.6.2
* Author : Christian Kehres
* Copyright : webtischlerei.de (c.kehres@webtischlerei.de)
* Created : 25.07.2008
* Modified : 17.09.2008
*****************************************************************/
// Original Contenidoklassen laden
cInclude('classes', 'class.article.php');
cInclude("classes", "contenido/class.clientslang.php");
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation.class.php');
cInclude('classes', 'Contenido_FrontendNavigation/Contenido_FrontendNavigation_Breadcrumb.class.php');
// Klasse zum auslesen globaler Variablen
class GetGlobals{
public function __construct(){
$this->db = $GLOBALS['db'];
$this->cfg = $GLOBALS['cfg'];
$this->client = $GLOBALS['client'];
$this->lang = $GLOBALS['lang'];
$this->cfgClient = $GLOBALS['cfgClient'];
$this->sess = $GLOBALS['sess'];
}
}
// Klasse zum auslesen der aktuellen Hauptkategorie
class Hauptkategorie extends GetGlobals{
public function auslesen($idcat){
$oBreadcrumb = new Contenido_FrontendNavigation_Breadcrumb($this->db, $this->cfg, $this->client, $this->lang, $this->cfgClient);
$oBreadCategories = $oBreadcrumb->get($idcat);
return $oBreadCategories[1]->getIdCat();
}
}
// Klasse zum verlinken von Kategorien und Artikeln
class Verlinkung extends GetGlobals{
public function verlinke($sMethode, $sKategorieID, $sArtikelID){
$sLink = 'front_content.php?idart='.$sArtikelID.'&idcat='.$sKategorieID.'&lang='.$this->lang.'&client='.$this->client.'';
return $this->generateLink($sLink, $sMethode);
}
private function generateLink($sLink, $sMethode){
switch($sMethode){
case "sess_url":
return $this->sess->url($sLink);
break;
case "mr_url":
return mr_build_new_url($sLink);
break;
case "cec_url":
return CEC_Hook::execute('Contenido.Frontend.CreateURL', $sLink);
break;
}
}
}
// Klasse zum auslesen der ID des aktuell benutzten Templates
class TemplateClass extends GetGlobals{
public function IDauslesen($idart){
$this->db->query('select'
. ' templateconf.idtpl as idtpl'
. ' from con_art_lang as artlang'
. ' left join con_cat_art as catart on artlang.idart = catart.idart'
. ' left join con_cat_lang as catlang on artlang.idlang = catlang.idlang and catart.idcat = catlang.idcat'
. ' left join con_template_conf as templateconf on templateconf.idtplcfg = if(artlang.idtplcfg > 0, artlang.idtplcfg, catlang.idtplcfg)'
. ' where'
. ' artlang.idartlang = '.$idart.'');
$this->db->next_record();
return $this->db->f('idtpl');
}
}
// Klasse zum auslesen der ID einer mit Namen benannten Kateogorie
class HauptkategorieClass extends GetGlobals {
public function IDauslesen($sHauptkategorieName){
$this->db->query('
SELECT A.idcat AS kategorie_id, B.name AS kategorie_name
FROM con_cat AS A, con_cat_lang AS B
WHERE B.name = "'.$sHauptkategorieName.'"
AND A.idcat = B.idcat
AND A.idclient = "'.$this->client.'"
');
$this->db->next_record();
return $this->db->f('kategorie_id');
}
}
// Klasse zum speichern von Strings und anschließender Ausgabe
class SaveStrings{
public function write($string){
$this->string .= $string."\n";
}
public function read(){
return $this->string;
unset($this->string);
}
}
?>
Code: Alles auswählen
/******************************************************************
* CONTENIDO MODUL
*
* Modulname : W3C konforme und SEO optimierte Subnavigation
* Version : 0.6.9
* Author : Christian Kehres
* Copyright : webtischlerei.de (c.kehres@webtischlerei.de)
*
* Entwicklungsstand
* Contenido : Version 4.8.8
* Klasse : Version 0.6.2 (webtischlerei.class.php)
* ModRewrite : Version 0.4.5
*
* Created : 25.07.2008
* Modified : 17.09.2008
*******************************************************************/
// webtischlerei.de Klasse laden
cInclude('classes', 'webtischlerei.class.php');
// Klassen initialisieren
$oClientLang = new cApiClientLanguage(false, $client, $lang);
if($area = "tpl_cfg"){
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sHTagShow", "CMS_VALUE[1]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sHTagLink", "CMS_VALUE[2]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sHTagNumber", "CMS_VALUE[3]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sLinkMethode", "CMS_VALUE[4]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sListArticles", "CMS_VALUE[5]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sListArticlesAlways", "CMS_VALUE[6]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sA_LI_CLASS", "CMS_VALUE[7]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sK_LI_CLASS", "CMS_VALUE[8]");
$oClientLang->setProperty("templateconfig", "TPL".$idtpl."_CON".$cnumber."_sKA_LI_CLASS", "CMS_VALUE[9]");
}
?>
<table>
<tr><td colspan="2" style="height: 30px; vertical-align: bottom"><strong><?php echo i18n(mi18n("H-TAG")); ?></strong></td></tr>
<tr>
<td><?php echo i18n(mi18n("H-TAG über den Artikeln und Kategorien einblenden")); ?></td>
<td><label><input type="Checkbox" name="CMS_VAR[1]" value="1"<?php echo ( "CMS_VALUE[1]" ? ' checked' : '' ); ?>></label></td>
</tr>
<tr>
<td><?php echo i18n(mi18n("H-TAG verlinken")); ?></td>
<td><label><input type="Checkbox" name="CMS_VAR[2]" value="1"<?php echo ( "CMS_VALUE[2]" ? ' checked' : '' ); ?>></label></td>
</tr>
<tr>
<td><?php echo i18n(mi18n("H-TAG Wert (1 = h1 | 2 = h2 | usw.)")); ?></td>
<td><input type="text" class="text_medium" name="CMS_VAR[3]" value="CMS_VALUE[3]"></td>
</tr>
<tr><td colspan="2" style="height: 30px; vertical-align: bottom"><strong><?php echo i18n(mi18n("Artikeleigenschaften")); ?></strong></td></tr>
<tr>
<td><?php echo i18n(mi18n("Artikel der Unterkategorien einblenden")); ?></td>
<td><label><input type="Checkbox" name="CMS_VAR[5]" value="1"<?php echo ( "CMS_VALUE[5]" ? ' checked' : '' ); ?>></label></td>
</tr>
<tr>
<td><?php echo i18n(mi18n("Artikel der Unterkategorien auch anzeigen wenn diese garnicht aktiv ist")); ?></td>
<td><label><input type="Checkbox" name="CMS_VAR[6]" value="1"<?php echo ( "CMS_VALUE[6]" ? ' checked' : '' ); ?>></label></td>
</tr>
<tr><td colspan="2" style="height: 30px; vertical-align: bottom"><strong><?php echo i18n(mi18n("CSS")); ?></strong></td></tr>
<tr>
<td><?php echo i18n(mi18n("Klasse für die LIs von Artikeln")); ?></td>
<td><input type="text" class="text_medium" name="CMS_VAR[7]" value="CMS_VALUE[7]"></td>
</tr>
<tr>
<td><?php echo i18n(mi18n("Klasse für die LIs von Unterkategorien")); ?></td>
<td><input type="text" class="text_medium" name="CMS_VAR[8]" value="CMS_VALUE[8]"></td>
</tr>
<tr>
<td><?php echo i18n(mi18n("Klasse für die LIs von Artikeln in Unterkategorien")); ?></td>
<td><input type="text" class="text_medium" name="CMS_VAR[9]" value="CMS_VALUE[9]"></td>
</tr>
<tr><td colspan="2" style="height: 30px; vertical-align: bottom"><strong><?php echo i18n(mi18n("verschiedenes")); ?></strong></td></tr>
<tr>
<td><?php echo i18n(mi18n("Verlinkungsmethode")); ?></td>
<td>
<select name="CMS_VAR[4]">
<option value="sess_url"<?php if("CMS_VALUE[4]" == "sess_url") echo "selected"; ?>>sess_url</option>
<option value="mr_url"<?php if("CMS_VALUE[4]" == "mr_url") echo "selected"; ?>>mr_url</option>
<option value="cec_url"<?php if("CMS_VALUE[4]" == "cec_url") echo "selected"; ?>>cec_url</option>
</select>
</td>
<tr>
<tr>
<td></td>
<td>
<strong>sess_url</strong><br />
<code>$sess->url($url);</code><br />
<br />
<strong>mr_url</strong><br />
<code>mr_build_new_url($url);</code><br />
<br />
<strong>cec_url</strong><br />
<code>CEC_Hook::execute('Contenido.Frontend.CreateURL', $url);</code>
</td>
</tr>
</table>
<?php
Code: Alles auswählen
<?php
// webtischlerei.de Klasse laden
cInclude('classes', 'webtischlerei.class.php');
// verschiedenste Contenido Klassen initialisieren
$oClientLang = new cApiClientLanguage(false, $client, $lang);
$oNavigation = new Contenido_FrontendNavigation($db, $cfg, $client, $lang, $cfgClient);
$oHauptkategorieName = new Cat;
// verschiedenste eigene Klassen initialisieren
$oHauptkategorie = new Hauptkategorie();
$oVerlinkung = new Verlinkung();
$oTpl = new TemplateClass();
$oSubnavigation = new SaveStrings();
// Werte auslesen
$sIDtpl = $oTpl->IDauslesen($idart);
$sHauptkategorieID = $oHauptkategorie->auslesen($idcat);
// Werte vom Input auslesen
$sHTagShow = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sHTagShow");
$sHTagNumber = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sHTagNumber");
$sHTagLink = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sHTagLink ");
$sLinkMethode = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sLinkMethode");
$sListArticles = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sListArticles");
$sListArticlesAlways = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sListArticlesAlways");
$sA_LI_CLASS = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sA_LI_CLASS");
$sK_LI_CLASS = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sK_LI_CLASS");
$sKA_LI_CLASS = $oClientLang->getProperty("templateconfig","TPL".$sIDtpl."_CON".$cCurrentContainer."_sKA_LI_CLASS");
// HTag erzeugen
if($sHTagShow == "1"){
$sHTagName = htmlentities($oHauptkategorieName->getCatName($sHauptkategorieID, $lang));
if($sHTagLink == "1"){
$sHTagUrl = $oVerlinkung->verlinke($sLinkMethode, $sHauptkategorieID, 0);
$oSubnavigation->write('<h'.$sHTagNumber.'><a href="'.$sHTagUrl.'">'.$sHTagName.'</a></h'.$sHTagNumber.'>');
} else {
$oSubnavigation->write('<h'.$sHTagNumber.'>'.$sHTagName.'</h'.$sHTagNumber.'>');
}
}
// Artikelliste erzeugen
$aOptions = array(
"idcat"=>$sHauptkategorieID,
"idlang"=>$lang,
"order"=>artsort,
"direction"=>desc,
"start"=>false,
"limit"=>0
);
$oArtikelliste = new ArticleCollection($aOptions);
while($oArtikel = $oArtikelliste->nextArticle()){
$sActive = ($oArtikel->getField('idart') == $idart) ? ' active' : '';
$oSubnavigation->write('<li class="'.$sA_LI_CLASS.''.$sActive.'"><a href="'.$oVerlinkung->verlinke($sLinkMethode, 0, $oArtikel->getField('idart')).'">'.htmlentities($oArtikel->getField('title')).'</a></li>');
}
// Unterkategorien mit deren Artikeln erzeugen
$oCategories = $oNavigation->getSubCategories($sHauptkategorieID);
if($oCategories->count() > 0){
$oSubnavigation->write('<ul>');
foreach($oCategories as $oCategory){
if($sListArticles == "1"){
if($oCategory->getIdCat() == $idcat || $sListArticlesAlways == "1"){
$aOptions = array(
"idcat"=>$oCategory->getIdCat(),
"idlang"=>$lang,
"order"=>artsort,
"direction"=>desc,
"start"=>false,
"limit"=>0
);
$oArtikelliste = new ArticleCollection($aOptions);
$sKAListe = '<ul>'."\n";
while($oArtikel = $oArtikelliste->nextArticle()){
$sActive = ($oArtikel->getField('idart') == $idart) ? ' active' : '';
$sKAListe .= '<li class="'.$sKA_LI_CLASS.''.$sActive.'"><a href="'.$oVerlinkung->verlinke($sLinkMethode, 0, $oArtikel->getField('idart')).'">'.htmlentities($oArtikel->getField('title')).'</a></li>'."\n";
}
$sKAListe .= '</ul>'."\n";
}
}
$sActive = ($oCategory->getIdCat() == $idcat) ? ' active' : '';
$oSubnavigation->write('<li class="'.$sK_LI_CLASS.''.$sActive.'"><a href="'.$oVerlinkung->verlinke($sLinkMethode, $oCategory->getIdCat(), 0).'">'.htmlentities($oCategory->getCategoryLanguage()->getName()).'</a>'.$sKAListe.'</li>');
unset($sKAListe);
}
$oSubnavigation->write('</ul>');
}
// Subnavigation ausgeben
echo $oSubnavigation->read();
?>