diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php
index 58b79ff51..d0c4289cc 100644
--- a/modules/blockbestsellers/blockbestsellers.php
+++ b/modules/blockbestsellers/blockbestsellers.php
@@ -104,32 +104,69 @@ class BlockBestSellers extends Module
*/
public function getContent()
{
- $output = '
'.$this->displayName.'
';
+ $output = '';
if (Tools::isSubmit('submitBestSellers'))
{
- Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)Tools::getValue('always_display'));
- $output .= ''.$this->l('Settings updated').'
';
+ Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)Tools::getValue('PS_BLOCK_BESTSELLERS_DISPLAY'));
+ $output .= ''.$this->l('Settings updated').'
';
}
- return $output.$this->displayForm();
+ return $output.$this->renderForm();
}
- public function displayForm()
+ public function renderForm()
{
- return '
- ';
+ $fields_form = array(
+ 'form' => array(
+ 'legend' => array(
+ 'title' => $this->l('Settings'),
+ 'icon' => 'icon-star-empty'
+ ),
+ 'id_form' => 'step_carrier_general',
+ 'input' => array(
+ array(
+ 'type' => 'switch',
+ 'label' => $this->l('Always display this block'),
+ 'name' => 'PS_BLOCK_BESTSELLERS_DISPLAY',
+ 'is_bool' => true,
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
+ )
+ ),
+ 'submit' => array(
+ 'title' => $this->l('Save'),
+ 'class' => 'btn btn-primary')
+ ),
+ );
+
+ $helper = new HelperForm();
+ $helper->show_toolbar = false;
+ $helper->table = $this->table;
+ $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
+ $helper->default_form_language = $lang->id;
+ $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
+ $this->fields_form = array();
+ $helper->id = (int)Tools::getValue('id_carrier');
+ $helper->identifier = $this->identifier;
+ $helper->submit_action = 'submitBestSellers';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
+ $helper->token = Tools::getAdminTokenLite('AdminModules');
+ $helper->tpl_vars = array(
+ 'fields_value' => $this->getConfigFieldsValues(),
+ 'languages' => $this->context->controller->getLanguages(),
+ 'id_language' => $this->context->language->id
+ );
+
+ return $helper->generateForm(array($fields_form));
}
public function hookHeader($params)
@@ -191,4 +228,11 @@ class BlockBestSellers extends Module
$row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency);
return $result;
}
+
+ public function getConfigFieldsValues()
+ {
+ return array(
+ 'PS_BLOCK_BESTSELLERS_DISPLAY' => Tools::getValue('PS_BLOCK_BESTSELLERS_DISPLAY', Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')),
+ );
+ }
}
\ No newline at end of file