name = 'blockmanufacturer'; $this->tab = 'Blocks'; $this->version = 1.0; parent::__construct(); $this->displayName = $this->l('Manufacturers block'); $this->description = $this->l('Displays a block of manufacturers/brands'); } function install() { parent::install(); $this->registerHook('leftColumn'); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true); } function hookLeftColumn($params) { global $smarty, $link; $smarty->assign(array( 'manufacturers' => Manufacturer::getManufacturers(), 'link' => $link, 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('MANUFACTURER_DISPLAY_FORM'), )); return $this->display(__FILE__, 'blockmanufacturer.tpl'); } function hookRightColumn($params) { return $this->hookLeftColumn($params); } function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockManufacturers')) { $text_list = intval(Tools::getValue('text_list')); $text_nb = intval(Tools::getValue('text_nb')); $form_list = intval(Tools::getValue('form_list')); if ($text_list AND !Validate::isUnsignedInt($text_nb)) $errors[] = $this->l('Invalid number of elements'); elseif (!$text_list AND !$form_list) $errors[] = $this->l('Please activate at least one system list'); else { Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', $text_list); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', $text_nb); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', $form_list); } 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 = '
'.$this->l('Settings').'
   '.$this->l('Display').' '.$this->l('elements').'

'.$this->l('To display manufacturers in a plain-text list').'

'.$this->l('To display manufacturers in a drop-down list').'

'; return $output; } } ?>