loupiloop Posted October 24, 2015 Share Posted October 24, 2015 Bonjour J'ai rajouté le module "produits phares sur la page d'accueil", j'ai sélectionné 4 produits. Ca s'affiche bien sur la page d'accueil. Maintenant, j'aimerais rajouté le nom de chaque catégorie au dessus de chaque produit. Comment faire svp ? J'ai tenté de rajouter cela dans un fichier product-list.tpl <p>{$category->name|escape:'htmlall':'UTF-8'} test</p> Mais la valeur ne s'affiche pas. alors que le texte "test" oui. Merci Link to comment Share on other sites More sharing options...
hilflo Posted October 25, 2015 Share Posted October 25, 2015 Tu peux rajouter cette fonction dans la classe Tools (Tools.php) de préférence dans un override : public static function getCategoryById($id_category, $id_lang = null) { if ($id_lang === null) $id_lang = Context::getContext()->language->id; $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, cl.`id_lang` FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').') '.Shop::addSqlAssociation('category', 'c').' WHERE cl.`id_lang` = '.(int)$id_lang.' AND c.`id_category` = '.$id_category); return $results; } Ensuite, dans product-list.tpl tu mets : <p> {assign var=cat_data value=Tools::getCategoryById($product.id_category_default)}{$cat_data.name} </p> et si tu veux ajouter un lien : <p> {assign var=cat_data value=Tools::getCategoryById($product.id_category_default)} <a href="{$link->getCategoryLink($cat_data.id_category,$cat_data.link_rewrite)}">{$cat_data.name}</a> </p> Link to comment Share on other sites More sharing options...
loupiloop Posted May 31, 2018 Author Share Posted May 31, 2018 C'était y a longtemps mais Merci !!! 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