GT ITECH Posted January 22, 2015 Share Posted January 22, 2015 (edited) Hello, for an unknown reason, i have a problem for showing the "Configure" button for this module. Here is my displayform and getContent function : private function _displayForm() { $langdef = Configuration::get('PS_LANG_DEFAULT'); $this->_html .= '<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data"> <fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" />'.$this->l('Settings').'</legend> <table border="0" width="600" cellpadding="0" cellspacing="0" id="form"> <tr><td width="270" style="height: 35px;">'.$this->l('Attribute group used for color choosing').' :</td> <td> <select id="group" name = "group">'; $sql = 'SELECT * FROM '._DB_PREFIX_.'attribute_group WHERE group_type = "color"'; if ($results = Db::getInstance()->ExecuteS($sql)) foreach ($results as $row) { $results2 = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'attribute_group_lang WHERE id_attribute_group = '.$row['id_attribute_group'].' AND id_lang = '.$langdef); $this->_html .= '<option value="'.$row['id_attribute_group'].'" >'.$results2['public_name'].'</option>'; } $this->_html .= ' </select> </td> </tr> <tr> <tr><td width="249"> </td></tr> <tr><td width="250"></td> <td width="380" style="margin-top: 35px;"> <input type="submit" class="button" name="submit" value="'.$this->l('Save').'" /></td></tr> <tr><td width="50"> </td></tr> <td width="250"></td><td id="frm"></td></tr> </table> </fieldset> </form> '; } public function getContent() { if (Tools::isSubmit('submit')) { Configuration::updateValue('Colorizator', Tools::getValue('group')); } $this->_displayForm(); return $this->_html; } Thank in advance for your response ^^ Edited July 31, 2015 by GT ITECH (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 22, 2015 Share Posted January 22, 2015 displayForm() instead of _displayForm() Link to comment Share on other sites More sharing options...
GT ITECH Posted January 22, 2015 Author Share Posted January 22, 2015 I will try this but i don't know what it doesn't work with _displayForm() because i use exactly this syntax in another module and it work fine Link to comment Share on other sites More sharing options...
vekia Posted January 22, 2015 Share Posted January 22, 2015 i've noticed something in addition to what i said you have to return public function getContent(){if (Tools::isSubmit('submit')){Configuration::updateValue('Colorizator', Tools::getValue('group'));} return $this->_displayForm();} Link to comment Share on other sites More sharing options...
GT ITECH Posted January 22, 2015 Author Share Posted January 22, 2015 (edited) Hello, thank you for your help, but it still doesn't work :/ Here is the complete code : /** * 2007-2014 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class Colorizator extends Module { /* @var boolean error */ protected $_errors = false; private $_html = ''; public function __construct() { $this->name = 'colorizator'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'TheMax98000'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Colorizator'); $this->description = $this->l('Automatically generate product images colors from svg file.'); } public function install() { return (parent::install() && $this->registerHook('displayAdminProductsExtra')); } public function uninstall() { if (!parent::uninstall()) return false; return true; } private function displayForm() { $langdef = Configuration::get('PS_LANG_DEFAULT'); $this->_html .= '<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data"> <fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" />'.$this->l('Settings').'</legend> <table border="0" width="600" cellpadding="0" cellspacing="0" id="form"> <tr><td width="270" style="height: 35px;">'.$this->l('Attribute group used for color choosing').' :</td> <td> <select id="group" name = "group">'; $sql = 'SELECT * FROM '._DB_PREFIX_.'attribute_group WHERE group_type = "color"'; if ($results = Db::getInstance()->ExecuteS($sql)) foreach ($results as $row) { $results2 = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'attribute_group_lang WHERE id_attribute_group = '.$row['id_attribute_group'].' AND id_lang = '.$langdef); $this->_html .= '<option value="'.$row['id_attribute_group'].'" >'.$results2['public_name'].'</option>'; } $this->_html .= ' </select> </td> </tr> <tr> <tr><td width="249"> </td></tr> <tr><td width="250"></td> <td width="380" style="margin-top: 35px;"> <input type="submit" class="button" name="submit" value="'.$this->l('Save').'" /></td></tr> <tr><td width="50"> </td></tr> <td width="250"></td><td id="frm"></td></tr> </table> </fieldset> </form> '; } public function prepareNewTab() { $this->context->smarty->assign(array( 'idprod' => Tools::getValue('id_product'), 'default_language' => (int)Configuration::get('PS_LANG_DEFAULT'), 'rand' => rand(0, 100000) )); $this->context->smarty->assign('colors', $this->getcolors((int)Configuration::get('PS_LANG_DEFAULT'))); } public function hookDisplayAdminProductsExtra($params) { if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) { $this->prepareNewTab(); return $this->display(__FILE__, '/views/templates/admin/newfieldstut.tpl'); } } public function getcolors($lang) { $result = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'attribute WHERE color != "" AND id_attribute_group = '.Configuration::get('Colorizator')); if (!$result) return array(); $getcolors = array(); foreach ($result as $field) { $result2 = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'attribute_lang WHERE id_attribute = '.$field['id_attribute'].' AND id_lang = '.$lang); $name = strtr($result2['name'], 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); array_push($getcolors, array('id' => $field['id_attribute'], 'name' => $name,'color' => $field['color'])); } return $getcolors; } public function getContent() { if (Tools::isSubmit('submit')) { Configuration::updateValue('Colorizator', Tools::getValue('group')); } $this->displayForm(); return $this->_html; } } I have missed anything ? Edited January 22, 2015 by TheMax98000 (see edit history) Link to comment Share on other sites More sharing options...
GT ITECH Posted January 24, 2015 Author Share Posted January 24, 2015 Up please i really need help :/ Link to comment Share on other sites More sharing options...
GT ITECH Posted July 31, 2015 Author Share Posted July 31, 2015 (edited) Hi just to say it's solved u_uGuys don't be an idiot like me, make sure the is configurable tag have the value 1 in config.xml.... Like this : <?xml version="1.0" encoding="UTF-8" ?> <module> <name>mymodule</name> <displayName><![CDATA[My Module]]></displayName> <version><![CDATA[1.0]]></version> <description><![CDATA[This is my module.]]></description> <author><![CDATA[MYNAME]]></author> <tab><![CDATA[front_office_features]]></tab> <is_configurable>1</is_configurable> <need_instance>0</need_instance> <limited_countries></limited_countries> </module> Edited July 31, 2015 by GT ITECH (see edit history) 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