robdk Posted January 23, 2014 Share Posted January 23, 2014 Witam z ponownym pytaniem Potrzebuje ustalić które kategorie są główne a które są podkategoriami za pomocą smarty. Chcę dla kategorii głównych w module blockcategories2 ustalić inny styl dla hover i nie wiem jakim warunkiem ten fakt sprawdzić. Która zmienna przechowuje takie dane? PZDR robdk Link to comment Share on other sites More sharing options...
vekia Posted January 23, 2014 Share Posted January 23, 2014 level_depth jeżeli jest równe 2 to kategoria jest kategorią główną Link to comment Share on other sites More sharing options...
robdk Posted January 23, 2014 Author Share Posted January 23, 2014 To jeszcze jedno, bo nie mogę tego wywołać w pliku tpl. Jest to zmienna $level_depth, czy parametr innej zmiennej tablicowej? Link to comment Share on other sites More sharing options...
robdk Posted January 24, 2014 Author Share Posted January 24, 2014 Kurcze próbuję i próbuję i nie wiem jak wywołać tą zmienną np. by wyświetlić wartość koło kategorii coś w stylu jak jest zrobiona ilość produktów w kategorii (oczywiście testowo by się zorientować w wartościach) coś w stylu ({$node.productsCount}) Próbowałem ({$node.level_depth}), ({$level_depth}) i brak efektów. Link to comment Share on other sites More sharing options...
vekia Posted January 24, 2014 Share Posted January 24, 2014 fakt, trzeba zmodyfikować moduł aby tę wartość dołączył do tablicy skorzystaj z tej funkcji: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = null, $currentDepth = 0) { if (is_null($id_category)) $id_category = $this->context->shop->getCategory(); $children = array(); if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (!isset($resultIds[$id_category])) return false; $return = array('level_depth'=>$resultIds[$id_category]['level_depth'], 'id' => $id_category, 'link' => $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'], 'children' => $children); return $return; } (dodałem level_depth do tablicy w $return. oraz to zapytanie: if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT DISTINCT c.level_depth, c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite FROM `'._DB_PREFIX_.'category` c INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').') INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)$this->context->shop->id.') WHERE (c.`active` = 1 OR c.`id_category` = '.(int)Configuration::get('PS_HOME_CATEGORY').') AND c.`id_category` != '.(int)Configuration::get('PS_ROOT_CATEGORY').' '.((int)$maxdepth != 0 ? ' AND `level_depth` <= '.(int)$maxdepth : '').' AND c.id_category IN (SELECT id_category FROM `'._DB_PREFIX_.'category_group` WHERE `id_group` IN ('.pSQL($groups).')) ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'cs.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) return; dodałem : c.level_depth na początku zapytania odtąd możliwe będzie wykorzystanie {$node.level_depth} Link to comment Share on other sites More sharing options...
robdk Posted January 24, 2014 Author Share Posted January 24, 2014 Dzięki - działa Nieźle się nakombinowałem by znaleźć rozwiązanie. Zapytanie już miałem zrobione. Troszkę po omacku bo nie zaglądałem do bazy. Niemniej rozszerzenie tablicy mi nie wpadło do głowy. Jeszcze raz dzięki Link to comment Share on other sites More sharing options...
Recommended Posts