kek83 Posted August 20, 2015 Share Posted August 20, 2015 Bonjour à tous, je débute dans la prog presta, vous excuserez donc mes errements techniques... Je suis sur presta 1.6.0.14 J'ai besoin de récupérer dans blocktopmenu.tpl l'ID de la catégorie avec un depth_level à 2. Exemple : CatAcceuil---CatA------SousCatA----------SousSousCatA > je suis sur la page présentant les articles de cette catégorie Je souhaites récupérer l'ID de la CatA... Pour cela j'ai donc écrit un petit bout de code dans blocktopmenu.php (est-ce le bon endroit ? ) dans la fonction generateCategoriesMenu : if((int)Tools::getValue('id_category') == (int)$category['id_category']) { function catmat($IdCat) { $parentCategory = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT DISTINCT c.id_category,c.id_parent, c.level_depth FROM '._DB_PREFIX_.'category c WHERE c.id_category = '.$IdCat.''); if($parentCategory[0]['level_depth'] > 2) { catmat($parentCategory[0]['id_parent']); } else { echo $devkek=(int)$parentCategory[0]['id_category']; return $devkek; } } $this->smarty->assign('CATACTIVE', catmat((int)$category['id_category'])); } Le souci est que le 'echo' m'affiche bien la valeur mais que le return ne me renvoie rien... Auriez-vous la gentillesse de m'aiguiller sur ce point ? Merci d'avance Mathieu Link to comment Share on other sites More sharing options...
EISEAL Posted August 20, 2015 Share Posted August 20, 2015 Salut, Je remplacerais : echo $devkek=(int)$parentCategory[0]['id_category']; return $devkek; par : $devkek=(int)$parentCategory[0]['id_category']; et j'ajouterais : $this->smarty->assign('DEVKEK', $devkek); Après : $this->smarty->assign('CATACTIVE', catmat((int)$category['id_category'])); Ce qui te permettrais théoriquement d'utiliser {$DEVKEK} dans ton TPL PS : J'ai pas testé Link to comment Share on other sites More sharing options...
kek83 Posted August 20, 2015 Author Share Posted August 20, 2015 Ok ça fonctionne ! Merci bcps de ton aide 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now