seldon.paul2 Posted November 19, 2010 Share Posted November 19, 2010 I have a module called blocknewproducts, which works fine.I wanted to create the block behave the same thing but not the new product, newproducts but recommended products, rproducts.So, I basically changes the word new in the newproduts block to r.But, very predictably it doesn't work.Here is the code(1) newproducts.php <?php class BlockNewProducts extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'blocknewproducts'; $this->tab = 'Blocks'; $this->version = 0.9; parent::__construct(); $this->displayName = $this->l('New products block'); $this->description = $this->l('Displays a block featuring newly added products'); } function install() { if (parent::install() == false OR $this->registerHook('rightColumn') == false OR Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false) return false; return true; } public function getContent() { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitBlockNewProducts')) { if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) $output .= ''.$this->l('You should fill the "products displayed" field').''; elseif (intval($productNbr) == 0) $output .= ''.$this->l('Invalid number.').''; else { Configuration::updateValue('NEW_PRODUCTS_NBR', intval($productNbr)); $output .= 'l('Confirmation').'" />'.$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('Products displayed').' <input type="text" name="productNbr" value="'.intval(Configuration::get('NEW_PRODUCTS_NBR')).'" /> '.$this->l('Set the number of products to be displayed in this block').' <input type="submit" name="submitBlockNewProducts" value="'.$this->l('Save').'" class="button" /> </form>'; return $output; } function hookRightColumn($params) { global $smarty; $currency = new Currency(intval($params['cookie']->id_currency)); $newProducts = [b][u]Product::getNewProducts[/u][/b](intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR')); $new_products = array(); if ($newProducts) foreach ($newProducts AS $newProduct) $new_products[] = $newProduct; $smarty->assign(array( 'new_products' => $new_products, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blocknewproducts.tpl'); } function hookLeftColumn($params) { return $this->hookRightColumn($params); } } ?> Link to comment Share on other sites More sharing options...
seldon.paul2 Posted November 19, 2010 Author Share Posted November 19, 2010 (2) rproducts.php <?php class BlockRProducts extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'blockrproducts'; $this->tab = 'Blocks'; $this->version = 0.9; parent::__construct(); $this->displayName = $this->l('Recommended products block'); $this->description = $this->l('Displays a block featuring recommended products'); } function install() { if (parent::install() == false OR $this->registerHook('rightColumn') == false OR Configuration::updateValue('R_PRODUCTS_NBR', 5) == false) return false; return true; } public function getContent() { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitBlockRProducts')) { if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) $output .= ''.$this->l('You should fill the "products displayed" field').''; elseif (intval($productNbr) == 0) $output .= ''.$this->l('Invalid number.').''; else { Configuration::updateValue('R_PRODUCTS_NBR', intval($productNbr)); $output .= 'l('Confirmation').'" />'.$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('Products displayed').' <input type="text" name="productNbr" value="'.intval(Configuration::get('R_PRODUCTS_NBR')).'" /> '.$this->l('Set the number of products to be displayed in this block').' <input type="submit" name="submitBlockRProducts" value="'.$this->l('Save').'" class="button" /> </form>'; return $output; } function hookRightColumn($params) { global $smarty; $currency = new Currency(intval($params['cookie']->id_currency)); $rProducts = [b][u]Product::getNewProducts[/b][/u](intval($params['cookie']->id_lang), 0, Configuration::get('R_PRODUCTS_NBR')); $r_products = array(); if ($rProducts) foreach ($rProducts AS $r_products) $r_products[] = $r_products; $smarty->assign(array( 'r_products' => $r_products, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockrproducts.tpl'); } function hookLeftColumn($params) { return $this->hookRightColumn($params); } } ?> Any help for the reason why rproducts doesn't work?I think in my opinion, getNewproducts ---> getRProducts, how I should name this procedure or function? Link to comment Share on other sites More sharing options...
freedux Posted November 24, 2010 Share Posted November 24, 2010 Bjr,es ce que tu vois apparaitre ton module blockrproducts dans le BO ? Link to comment Share on other sites More sharing options...
seldon.paul2 Posted November 24, 2010 Author Share Posted November 24, 2010 J'ai aucune idée. S'il vous plaît écrire en anglais. Il s'agit d'un forum en anglais? Bonjour? Yes, the folder name was identical, blockrproducts. 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