WDC
"myXOOPs"-Profi
Gepostet am:13.03.2021 19:16
#51
/** @var XoopsModulesWggalleryHelper $helper */
$helper = Helper::getInstance();
$albumsHandler = $helper->getHandler('Category');
$crAlbums = new CriteriaCompo();
$crAlbums->add(new Criteria('cid', $cid));
$crAlbums = new CriteriaCompo();
$crAlbums->add(new Criteria('cid', $cid));
function getParentsOfCategory($cid)
{
$parentsAll = [];
/** @var XoopsModulesWggalleryHelper $helper */
$helper = Helper::getInstance();
$albumsHandler = $helper->getHandler('Category');
$crAlbums = new CriteriaCompo();
$crAlbums->add(new Criteria('cid', $cid));
$albumsCount = $albumsHandler->getCount($crAlbums);
$albumsAll = $albumsHandler->getAll($crAlbums);
// Table view albums
if ($albumsCount > 0) {
foreach (array_keys($albumsAll) as $i) {
$parentsAll[] = ['cid' => $albumsAll[$i]->getVar('cid'), 'title' => $albumsAll[$i]->getVar('title'), 'pid' => $albumsAll[$i]->getVar('pid')];
$parent = getParentsOfCategory($albumsAll[$i]->getVar('pid'));
if ($parent) {
$parentsAll[] = $parent;
}
}
}
return $parentsAll;
}
// Parent Kategorien
$xoBreadcrumbs[] = ['title' => $parentsAll];
$helper = XoopsModulesWggalleryHelper::getInstance();
foreach ($GLOBALS['cattree']->getAllChild($cid) as $child) {
$cids[$child->getVar('cid')] = $child->getVar('cid');
}
$cids[] = $cid;
$criteria = new CriteriaCompo(new Criteria('status', '0', '>'));
$photo_total_sum = Utility::getTotalCount($cids, $criteria);
if (!empty($cids)) {
foreach ($cids as $index => $child) {
$childcat = $catHandler->get($child);
if (is_object($childcat)) {
$catpath .= "<a href='" . $helper->url() . 'viewcat.php?num=' . (int)$GLOBALS['merchandise_perpage'] . '&cid=' . $childcat->getVar('cid') . "' >" . $childcat->getVar('title') . '</a> ' . ($index < count($cids) ? '>>' : '');
}
}
} else {
$cat = $catHandler->get($cid);
$catpath .= "<a href='" . $helper->url() . 'viewcat.php?num=' . (int)$GLOBALS['merchandise_perpage'] . '&cid=' . $cat->getVar('cid') . "' >" . $cat->getVar('title') . '</a>';
}
/**
* Get all parents of a category
* @param $albPid
* @return string
*/
function getParentsOfCategory($cat)
{
$parentsAll = [];
/** @var XoopsModulesWggalleryHelper $helper */
$helper = XoopsModulesWggalleryHelper::getInstance();
$albumsHandler = $helper->getHandler('Category');
$crAlbums = new CriteriaCompo();
$crAlbums->add(new Criteria('cid', $cid));
$albumsCount = $albumsHandler->getCount($crAlbums);
$albumsAll = $albumsHandler->getAll($crAlbums);
// Table view albums
if ($albumsCount > 0) {
foreach (array_keys($albumsAll) as $i) {
$parentsAll[] = ['cid' => $albumsAll[$i]->getVar('cid'), 'title' => $albumsAll[$i]->getVar('title'), 'pid' => $albumsAll[$i]->getVar('pid')];
$parent = getParentsOfCategory($albumsAll[$i]->getVar('pid'));
if ($parent) {
$parentsAll[] = $parent;
}
}
}
return $parentsAll;
}
/**
* Get all parents of a category
* @param $albPid
* @return string
*/
function getParentsOfCategory($albId)
{
$parentsAll = [];
/** @var XoopsModulesWggalleryHelper $helper */
$helper = XoopsModulesWggalleryHelper::getInstance();
$albumsHandler = $helper->getHandler('Albums');
$crAlbums = new CriteriaCompo();
$crAlbums->add(new Criteria('cid', $albId));
$albumsCount = $albumsHandler->getCount($crAlbums);
$albumsAll = $albumsHandler->getAll($crAlbums);
// Table view albums
if ($albumsCount > 0) {
foreach (array_keys($albumsAll) as $i) {
$parentsAll[] = ['cid' => $albumsAll[$i]->getVar('cid'), 'title' => $albumsAll[$i]->getVar('title'), 'pid' => $albumsAll[$i]->getVar('pid')];
$parent = getParentsOfCategory($albumsAll[$i]->getVar('pid'));
if ($parent) {
$parentsAll[] = $parent;
}
}
}
return $parentsAll;
}
Eine Elternkategorie bekomme ich ja evtl. noch hin. Den Rest bisher nicht
Goffy schrieb:
Hi
Zitat:Na das wird ja was
super![]()
den Modulnamen solltest du über$GLOBALS['xoopsModule']->getVar('name');
erhalten
Goffy schrieb:wegen Namen der aktuellen Kategorie:
da musst du mal die Variablen checken, die du auf der Seite verwendest, ob da die übergeordnete Kategorie irgendwo drin ist.
ansonsten müsstest du die Parent-Id zur aktuellen Kategorie abfragen
| Forum | Thema | Antworten | Views | Letzter Beitrag |
|---|---|---|---|---|
| Modulentwicklung | New Xoops Xcreate Module | 0 | 5490 | 26.11.2025 15:22 efkan |
| Modulentwicklung | XOOPS Custom Field Module | 1 | 1899 | 24.11.2025 11:21 Goffy |