sampla Posted November 26, 2010 Share Posted November 26, 2010 Bonjour,Je voudrais affiché pour les produit phare plusieur catégorie en page d'accueille code d'origine <?php if (!defined('_CAN_LOAD_FILES_')) exit; class HomeFeatured extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'homefeatured'; $this->tab = 'Tools'; $this->version = '0.9'; parent::__construct(); $this->displayName = $this->l('Featured Products on the homepage'); $this->description = $this->l('Displays Featured Products in the middle of your homepage'); } function install() { if (!Configuration::updateValue('HOME_FEATURED_NBR', 8) OR !parent::install() OR !$this->registerHook('home')) return false; return true; } public function getContent() { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitHomeFeatured')) { $nbr = intval(Tools::getValue('nbr')); if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr)) $errors[] = $this->l('Invalid number of product'); else Configuration::updateValue('HOME_FEATURED_NBR', intval($nbr)); if (isset($errors) AND sizeof($errors)) $output .= $this->displayError(implode(' ', $errors)); else $output .= $this->displayConfirmation($this->l('Settings updated')); } return $output.$this->displayForm(); } public function displayForm() { $output = ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> _path.'logo.gif" alt="" title="" />'.$this->l('Settings').' '.$this->l('In order to add products to your homepage, just add them to the "home" category.').' '.$this->l('Number of product displayed').' <input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', intval(Configuration::get('HOME_FEATURED_NBR'))).'" /> '.$this->l('The number of products displayed on homepage (default: 10)').' <input type="submit" name="submitHomeFeatured" value="'.$this->l('Save').'" class="button" /> </form>'; return $output; } function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); } } j'ai essayé de mettre $category = new Category(50); $category = new Category(52); mais ça marche pasou alors dédoubler le bloc mais il affiche uniquement la 2eme (Cat52) $category = new Category(50); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); $category = new Category(52); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); Comment je peux faire ?merci encore Link to comment Share on other sites More sharing options...
coeos.pro Posted November 26, 2010 Share Posted November 26, 2010 Bonjour, c'est normal qu'il affiche que le 2ème, $smarty->assign(array('products' =>... signifie qu'il envoi des valeurs (ex:$product) dans smarty via un tableau (array) et que l'affichage se fait grâce au fichier homefeatured.tplCe que vous avez mis correspond à 'product'=50 ensuite 'product'=52, et dans homefeatured vous afficher product, donc 52.Ce qu'il faudrait faire c'est mettre 2 fois le code mais avec des noms de variables différentes: $smarty->assign(array('products50' => ... et $smarty->assign(array('products52' => et dans homefeatured.tpl changer le code en conséquence {$product50} et {$product52} au lieu de {$product} Link to comment Share on other sites More sharing options...
sampla Posted November 26, 2010 Author Share Posted November 26, 2010 merci j'ai essayé mais ça marche pasest-ce que je pourrais avoir le code complet pour copier coller, car je doute de pouvoir le faire moi même 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