
Mcey
Members-
Posts
7 -
Joined
-
Last visited
Everything posted by Mcey
-
Bonjour, J'ai créé un module sur Prestashop 1.6.1.18. Tout fonctionne sauf la traduction automatique. Je suis en train de recetter et étant nouvelle dans me monde de prestashop je ne vois pas comment faire. Au moment de la création de mon module j'ai utilisé le backoffice pour effectuer mes traductions en français. J'ai donc un dossier translations > avec un fichier fr.php. Le soucis est que lorsque que je met le dossier de mon module sur mon ftp, mon fichier fr.php n'est pas repris automatique dans le thème. Faut-il faire une action précise ? Auriez-vous un conseil ? Merci.
-
Hello, The tuto is very helpful. But I can't get the part the checked box is checked after we load the submitted. Can you give more details on the process to get the values of the checkbox field and put the checked please ? Thanks.
- 6 replies
-
- ecommerce
- ecommerce tutorial
- (and 6 more)
-
I found it out. It was just in my install() function, it wasn't complete : Here is the good code : public function install() { if (Shop::isFeatureActive()){ Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('backOfficeHeader') || !Configuration::updateValue('MYMODULE_PRESTA', 'Module presta') ) return false; return true && ($this->registerHook('displayHeader') || $this->registerHook('backOfficeHeader')); }
-
Bonjour, Je suis en train de créer un module sur prestashop 1.7 et je souhaiterais modifier les css du module, côté ADMIN. Dans mon fichier principal .php j'ai fais un hook : public function install() { if (Shop::isFeatureActive()){ Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install() || !$this->registerHook('header') || !Configuration::updateValue('MYMODULE_PRESTA', 'Module presta') ) return false; return true && $this->registerHook('backOfficeHeader'); } public function hookBackOfficeHeader(){ $this->getContext()->controller->addCSS($this->_path.'views/css/modulepresta.css'); } Du coup ça ne fonctionne pas, donc j'ai créé un controller admin : <?php class AdminModulePresta extends ModuleAdminController { public function __construct() { $this->bootstrap = true; $this->className = 'AdminModulePrestaController'; include_once(_PS_MODULE_DIR_ . '/modulepresta/modulepresta.php'); parent::__construct(); } public function setMedia() { parent::setMedia(); $this->path = __PS_BASE_URI__.'modules/modulepresta/'; $this->context->controller->addCSS($this->path . 'views/css/modulepresta.css'); // $this->context->controller->addJS($this->path . 'js/lib/jquery.mousewheel.js'); } public function init() { parent::init(); } } Mais ça ne fonctionne toujours pas. Je vous envoie un écran du module ci-dessous, je souhaiterais juste mettre un display:flex en CSS sur mes Checkbox et boutons radio. Si vous auriez des suggestions ça m'aiderais. Je vous remercie.
-
Hi, Ok thanks ! I'm gonna try it ! ^^
- 5 replies
-
- prestashop 1.7
- radio button
-
(and 3 more)
Tagged with:
-
So, I found out how to code the form. Here is the code if someone is interested by prestashoop 1.7 form : <?php if (!defined('_PS_VERSION_')){ exit; } class ModulePresta extends Module{ public function __construct() { $this->name = 'modulepresta'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Prenom Nom'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Mon module presta'); $this->description = $this->l('Description of my module presta.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_PRESTA')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install() || !$this->registerHook('header') || !Configuration::updateValue('MYMODULE_PRESTA', 'Module presta') ) return false; return true; } public function uninstall(){ if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_PRESTA') ) return false; return true; } public function getContent(){ $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('MYMODULE_PRESTA')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('MYMODULE_PRESTA', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } Configuration::updateValue('MYMODULE_PRESTA1', Tools::getValue('MYMODULE_PRESTA1')); //Configuration::updateValue('density', Tools::getValue('density')); } return $output.$this->displayForm(); } public function displayForm(){ // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form = array(); $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value : '), 'name' => 'MYMODULE_PRESTA', 'size' => 20, 'required' => true ), // Select array( 'type' => 'select', 'label' => $this->l('Events:'), 'name' => 'events', 'required' => true, 'options' => array( 'query' => $idevents = array( array( 'idevents' => 1, 'name' => 'methode 1' ), array( 'idevents' => 2, 'name' => 'methode 2' ), array( 'idevents' => 3, 'name' => 'methode 3' ), ), 'id' => 'idevents', 'name' => 'name' ) ), // Checkbox array( 'type' => 'checkbox', 'label' => $this->l('Choix'), 'desc' => $this->l('Faites vos choix.'), 'name' => 'choix', 'values' => array( 'query' => $lesChoix = array( array( 'check_id' => '1', 'name' => $this->l('Valeur 1'), ), array( 'check_id' => '2', 'name' => $this->l('Valeur 2'), ), array( 'check_id' => '3', 'name' => $this->l('Valeur 3'), ) ), 'id' => 'check_id', 'name' => 'name', 'desc' => $this->l('Please select') ), // EN OPTION : On peut cacher les champs ici avec un bouton plus ou moins // 'expand' => array( // ['print_total'] => count($option), // 'default' => 'show', // 'show' => array('text' => $this->l('show'), 'icon' => 'plus-sign-alt'), // 'hide' => array('text' => $this->l('hide'), 'icon' => 'minus-sign-alt'), // ), ), // Radio button array( 'type' => 'radio', 'label' => $this->l('Density'), 'name' => 'density', 'class' => 't', 'required' => true, 'is_bool' => true, 'values' => array( array( 'id' => 'petit', 'value' => 0, 'label' => $this->l('petit') ), array( 'id' => 'moyen', 'value' => 1, 'label' => $this->l('moyen') ), array( 'id' => 'grand', 'value' => 2, 'label' => $this->l('grand') ) ), ), // Dates array( 'type' => 'date', 'label' => $this->trans('From', array(), 'Admin.Global'), 'name' => 'date_from', 'maxlength' => 10, 'required' => true, 'hint' => $this->trans('Format: 2011-12-31 (inclusive).', array(), 'Admin.Orderscustomers.Help') ), array( 'type' => 'date', 'label' => $this->trans('To', array(), 'Admin.Global'), 'name' => 'date_to', 'maxlength' => 10, 'required' => true, 'hint' => $this->trans('Format: 2012-12-31 (inclusive).', array(), 'Admin.Orderscustomers.Help') ) ),// --- end of input 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['MYMODULE_PRESTA'] = Configuration::get('MYMODULE_PRESTA'); $helper->fields_value['events'] = $idevents; // Pour le select $helper->fields_value['check_id'] = false; $helper->fields_value['density_active_on'] = true; $helper->fields_value = array( 'date_from' => date('Y-m-d'), 'date_to' => date('Y-m-d') ); return $helper->generateForm($fields_form); } public function initContent(){ $this->content .= $this->initFormByDate(); } } Now I am looking for how to save these information in an XML file. Questions remain unanswered regarding the different methods to use in a module. see you
- 5 replies
-
- 2
-
-
- prestashop 1.7
- radio button
-
(and 3 more)
Tagged with:
-
Hello, I would like to program a complete form with helperform on prestashop 1.7. with select, radio button and checkbox. My image attached. It would be an admin side module. And all the information will be stocked in an XML file. I’m in training course and I have 4 weeks to do it. I followed the tutorial at this address: http://doc.prestashop.com/display/PS17/Adding+a+configuration+page So I can just create inputs. Here is my code: <?php if (!defined('_PS_VERSION_')){ exit; } class ModulePresta extends Module { public function __construct() { $this->name = 'modulepresta'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Prenom Nom'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Mon module presta'); $this->description = $this->l('Description of my module presta.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_PRESTA')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install() || !$this->registerHook('header') || !Configuration::updateValue('MYMODULE_PRESTA', 'Module presta') ) return false; return true; } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_PRESTA') ) return false; return true; } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('MYMODULE_PRESTA')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('MYMODULE_PRESTA', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } Configuration::updateValue('MYMODULE_PRESTA1', Tools::getValue('MYMODULE_PRESTA1')); } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form = array(); $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value : '), 'name' => 'MYMODULE_PRESTA', 'size' => 20, 'required' => true ), array( 'type' => 'text', 'label' => $this->l('Heure : '), 'name' => 'MYMODULE_PRESTA1', 'size' => 20, 'required' => true ) ), array( 'type' => 'select', 'label' => $this->l('Languages:'), 'name' => 'category', 'required' => true, 'options' => array( 'query' => $options = array( array( 'id_option' => 1, // The value of the 'value' attribute of the <option> tag. 'name' => 'EN', // The value of the text content of the <option> tag. ), array( 'id_option' => 2, 'name' => 'BG', ), ), 'id' => 'id_option', 'name' => 'name', ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['MYMODULE_PRESTA'] = Configuration::get('MYMODULE_PRESTA'); $helper->fields_value['MYMODULE_PRESTA1'] = Configuration::get('MYMODULE_PRESTA1'); return $helper->generateForm($fields_form); } } Currently I managed to show that 2 inputs On the other hand I saw on other forums that it is necessary to use the following methods: public function renderForm () public function postProcess () while I only use the basic methods: public function getContent () public function displayForm () Your help would be precious to me.
- 5 replies
-
- prestashop 1.7
- radio button
-
(and 3 more)
Tagged with: