Achille Posted August 2, 2016 Share Posted August 2, 2016 Bonjour à tous. J'ai pas mal cherché sur le forum mais je n'ai pas trouvé de réponse simple et claire à ma question. Existe-t-il en natif une variable Smarty pour récupérer l'ID de la Root Category. Exemple : - Cat #1 -- Ss Cat #2 --- Ss Cat #3 Je suis dans la Ss Cat #3 et je veux conditionner l'affichage d'un content uniquement si la Root Category à un ID = 1. Hypothétiquement un truc du genre : {if $id_category_root == '1'} {hook h="myHook" mod="myModule"} {/if} Pardon d'être redondant, mais je souhaite être le plus clair possible. Merci d'avance à tous. Achille. Link to comment Share on other sites More sharing options...
doekia Posted August 2, 2016 Share Posted August 2, 2016 Configuration::get('PS_HOME_CATEGORY') ? ou encore $shop->id_category Link to comment Share on other sites More sharing options...
Achille Posted December 1, 2016 Author Share Posted December 1, 2016 La réponse : Dans .\controllers\front\CategoryController.php En fin de fichier rajouter : public function process() { global $cookie; $parent = new Category(Tools::getValue('id_category'), intval($cookie->id_lang)); $listing=$parent->getParentsCategories($cookie->id_lang); foreach ($listing as $list) { if($list['level_depth']==2) { self::$smarty->assign('id_root_cat',$list['id_category']); break; } } } Puis dans le TPL qui est concerné : {if isset($category)} <div class="my-class"> {if $id_category->id==12 || $id_root_cat == 12} <p>Your content</p> {elseif $id_category->id==13 || $id_root_cat == 13} <p>Your content</p> {elseif $id_category->id==14 || $id_root_cat == 14} <p>Your content</p> {elseif $id_category->id==16 || $id_root_cat == 16} <p>Your content</p> {/if} </div> {/if} SeeU 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