jrmvii Posted May 7, 2012 Share Posted May 7, 2012 (edited) Salut, Pour le moment pour personnaliser le contenu des templates je jongle entre. {if $page_name == 'XXX'} {/if} sur mon header.tpl et {if $category->id == XXX} {/if} sur mon product-list.tpl J'aimerais savoir s'il possible de faire de même pour les produits dans product-list.tpl style {if $product_id == 'XXX'}{/if} ? Et bien sûr si oui, comment ? merci pour votre aide Edited May 8, 2012 by jrmvii (see edit history) Link to comment Share on other sites More sharing options...
Junfan Posted May 8, 2012 Share Posted May 8, 2012 (edited) De la même manière que pour "category" ? {if $category->id_category == XX}{l s='TEST'} {/if} {if $product->id_product== XX}{l s='TEST'} {/if} Le mieux c'est d'essayer... Edited May 8, 2012 by Junfan (see edit history) Link to comment Share on other sites More sharing options...
Monte a bord Victor Posted May 8, 2012 Share Posted May 8, 2012 Bonjour, Vous pouvez le faire dans le foreach avec {if $product.id_product == XX}{l s='TEST'}{/if} Cordialement Link to comment Share on other sites More sharing options...
Junfan Posted May 8, 2012 Share Posted May 8, 2012 (edited) J'ai à mon tour besoin d'aide sur ce sujet : J'ai remarqué que cette méthode fonctionne par exemple dans le footer.tpl mais pas dans le header.tpl... J'imagine qu'il faut "overrider", mais je ne vois pas comment... Mon fichier FrontController.php ressemble à ca : <?php class FrontController extends FrontControllerCore { public function displayHeader() { $pathinfo = pathinfo(__FILE__); $page_name = basename($_SERVER['PHP_SELF'], '.'.$pathinfo['extension']); $page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name; if ($page_name == 'category' AND isset($_GET['id_category'])) { $category = new Category($_GET['id_category'], intval(self::$cookie->id_lang)); if (Validate::isLoadedObject($category)) self::$smarty->assign('category_name', $category->name); self::$smarty->assign('category', $category->id_category); } elseif ($page_name == 'product' AND isset($_GET['id_product'])) { $product = new Product($_GET['id_product'], false, intval(self::$cookie->id_lang)); if (Validate::isLoadedObject($product)) self::$smarty->assign('product_name', $product->name); } elseif ($page_name == 'manufacturer' AND isset($_GET['id_manufacturer'])) { $manufacturer = new Manufacturer($_GET['id_manufacturer'], false, intval(self::$cookie->id_lang)); if (Validate::isLoadedObject($manufacturer)) self::$smarty->assign('manufacturer_name', $manufacturer->name); } parent::displayHeader(); } } ?> J'arrive a personnaliser le header avec du code du genre : {if isset($category_name)} TEST {/if} mais pas avec {if $category.id_category == XX} TEST {/if} ni avec {if $category->id_category == XX} TEST {/if} Comment faire ? Merci ! Edited May 8, 2012 by Junfan (see edit history) Link to comment Share on other sites More sharing options...
Junfan Posted May 8, 2012 Share Posted May 8, 2012 Et bien il suffit de poser la question pour trouver la réponse... je fais décidément toujours ce coup là... Pour ceux que ca intéresse, la réponse est ici : http://www.prestashop.com/forums/topic/41013-solved-how-to-use-different-headers-according-to-sub-category-in-the-product-page/ Link to comment Share on other sites More sharing options...
Monte a bord Victor Posted May 8, 2012 Share Posted May 8, 2012 (edited) Bonsoir, A moins que je passe à côté de quelque chose vu l'heure tardive, vous passez à la vue les variables "category_name" et "category". Donc il est normal que ce que vous essayez ne fonctionne pas. Sans toucher à votre contrôleur actuel, si vous cherchez l'id_category, il est ici... {$category} puisque c'est ce que vous faîtes ici... self::$smarty->assign('category', $category->id_category); Cordialement Edited May 8, 2012 by Ixycom (see edit history) Link to comment Share on other sites More sharing options...
Junfan Posted May 8, 2012 Share Posted May 8, 2012 Merci beaucoup pour la réponse lixycom J'ai trouvé une autre solution qui apparemment évite de toucher au controleur : Dans le header.tpl je fais : {if $smarty.get.id_category == XX} TEST {/if} et ca marche ! 1 Link to comment Share on other sites More sharing options...
jrmvii Posted May 8, 2012 Author Share Posted May 8, 2012 superbe merci les gars, en effet il suffisait d'essayer ! Link to comment Share on other sites More sharing options...
Junfan Posted May 8, 2012 Share Posted May 8, 2012 De rien, content d'avoir pu aider, en plus ca m'a débloqué moi aussi.. Ca marche toujours mieux en équipe Link to comment Share on other sites More sharing options...
Monte a bord Victor Posted May 8, 2012 Share Posted May 8, 2012 Bonsoir, N'oubliez pas de marquer le post comme "résolu" ;-) Cordialement 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