Code: Alles auswählen
$oSubCategory
Code: Alles auswählen
$mycats[] = $oContenidoCategory->getIdCat();
Code: Alles auswählen
$oSubCategory
Code: Alles auswählen
$mycats[] = $oContenidoCategory->getIdCat();
Code: Alles auswählen
$iStartIdcat = 1037; //hier die gewünschte idcat eintragen
$iSelectedDepth = 2; // hier erstmla nicht gewünscht, es wird nur 1 Ebene ermittelt.
$oConCat = new Contenido_Category($db, $cfg);
$oConCat->setloadSubCategories(true,3);
$oConCat->load($iStartIdcat, true, $lang);
$sCat = $oConCat->getCategoryLanguage()->getName();
$oSubCategories = $oConCat->getSubCategories();
$oSub = $oConCat->getSubCategories();
if ($oSub->count() > 0) {
foreach ($oSub as $oContenidoCategory) {
$mycats[] = $oContenidoCategory->getIdCat();
}
}
genau dort liegt der Fehler, $oContenidoCategory ist nicht $oSubCategory.stefkey hat geschrieben:Code: Alles auswählen
foreach ($oSub as $oContenidoCategory) { $mycats[] = $oSubCategory->getIdCat(); }
Code: Alles auswählen
<?php
/**
* $RCSfile$
*
* Description: Output some HTML text
*
* @version 1.0.0
* @author Rudi Bieller
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2008-04-07
* }}
*
* $Id$
*/
// in $mycats werden nach und nach durch die Loops die Kategorie-IDs gespeichert.
if (!isset($db)) {
$db = new DB_Contenido();
}
$iStartIdcat = getEffectiveSetting('navigation_comments', 'idcat', 1);
$iSelectedDepth = getEffectiveSetting('navigation_comments', 'level-depth', 4);
if ($iStartIdcat > 0) {
$mycats[] = $iStartIdcat;
$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) {
$aDepthInfo = array();
$aDepthInfo[0] = 0;
$aDepthInfo[1] = $iSelectedDepth;
foreach ($oSubCategories as $oSubCategory) {
$mycats[] = $oSubCategory->getIdCat();
Contenido_GetSubs_Util::loopCats($oSubCategory, $oFeNav, $cfg, $lang, intval($idcat), $aDepthInfo);
}
print_r($mycats);
}
} else {
echo '<p>Navigation not configured correctly.</p>';
}
class Contenido_GetSubs_Util {
public static function loopCats(Contenido_Category $oCategory, Contenido_FrontendNavigation $oFrontendNavigation, array $aCfg, $iLang, $iCurrentPageIdcat, array $aDepthInfo = array()) {
global $mycats;
$aDepthInfo[0] = isset($aDepthInfo[0]) ? $aDepthInfo[0] + 1 : 1;
$aDepthInfo[1] = isset($aDepthInfo[1]) ? $aDepthInfo[1] : 1;
$oCurrentSubcategories = $oFrontendNavigation->getSubCategories($oCategory->getIdCat());
// continue until max level depth
if ($aDepthInfo[1] > $aDepthInfo[0]) {
// check if current item has sub-items to be displayed
if ( $oCurrentSubcategories->count() > 0) {
$oSubCategories = $oCurrentSubcategories;
foreach ($oSubCategories as $oSubCategory) {
$mycats[] = $oSubCategory->getIdCat();
self::loopCats($oSubCategory, $oFrontendNavigation, $aCfg, $iLang, $iCurrentPageIdcat, $aDepthInfo);
}
}
}
}
}
?>