dhobo Posted May 30, 2013 Share Posted May 30, 2013 Hello, I'm creating a simple module in which it should be possible to enter HTML / CSS / JS in the backend, this should be saved in the database, and in the frontend this should be parsed in a .tpl file and output the given HTML / CSS / JS. right now I have the following part to build a form: // form for settings $aFormFields = array(); $aFormFields[0]['form'] = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Parallax settings'), ), 'input' => array( array( 'type' => 'textarea', 'label' => $this->l('Upload images'), 'name' => 'PARALLEX_RTE_FIELD', 'cols' => 100, 'rows' => 60 ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $oHelper = new HelperForm(); // Module, token and currentIndex $oHelper->module = $this; $oHelper->name_controller = $this->name; $oHelper->token = Tools::getAdminTokenLite('AdminModules'); $oHelper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $oHelper->default_form_language = $iLang; $oHelper->allow_employee_form_lang = $iLang; // Title and toolbar $oHelper->title = $this->displayName; $oHelper->show_toolbar = true; // false -> remove toolbar $oHelper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $oHelper->submit_action = 'submit'.$this->name; $oHelper->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 values $oHelper->fields_value['PARALLEX_RTE_FIELD'] = Configuration::get('PARALLEX_RTE_FIELD'); $sReturn = $oHelper->generateForm($aFormFields); return $sReturn; this part to save it in the database: if (Tools::isSubmit('submit'.$this->name)){ Configuration::updateValue('PARALLEX_RTE_FIELD', Tools::getValue('PARALLEX_RTE_FIELD')); $sOutput .= $this->displayConfirmation($this->l('Changes saved')); } this part to give it to the template: $this->smarty->assign(array( 'parallax_data' => Configuration::get('PARALLEX_RTE_FIELD') )); return $this->display(__FILE__, 'parallax.tpl'); and this is how I show it in the template file: {$parallax_data} now my problem is that it seems that HTML data is being filtered out. my code works, in the frontend I can see that the data I insert in the backend is shown, but it's not working HTML anymore. What I would like is that literally what I enter in the backend is being shown as HTML in frontend.any clue on how to fix this? Link to comment Share on other sites More sharing options...
PascalVG Posted May 30, 2013 Share Posted May 30, 2013 I think in your writing the value to the database, you should add a , true to the statement: Configuration::updateValue('PARALLEX_RTE_FIELD', Tools::getValue('PARALLEX_RTE_FIELD'), true); in the file /classes/Configuration.php you can see the definition of the updateValue function. The third parameter defines if html is allowed or not: /** * Update configuration key and value into database (automatically insert if key does not exist) * * @param string $key Key * @param mixed $values $values is an array if the configuration is multilingual, a single string else. * @param boolean $html Specify if html is authorized in value <--- this defines if html values allowed or not * @param int $id_shop_group * @param int $id_shop * @return boolean Update result */ public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null) Default value is set to false, so if you turn it on, it might work as wanted. Give it a try and see if it helps. If not yet, we have to find out if there's more to do. My 2 cents, pascal 9 1 Link to comment Share on other sites More sharing options...
dhobo Posted May 30, 2013 Author Share Posted May 30, 2013 yep, that did the trick. thanks ! Link to comment Share on other sites More sharing options...
vekia Posted May 30, 2013 Share Posted May 30, 2013 thanks for information that it works now i can go ahead and mark this thread as [solved] you can also mark own threads as solved, read the instruction: To mark a topic as [solved] :- Edit the first post of your topic by clicking on the "Edit" button, - Click on the "Use full editor" button, - Add the "[solved]" string at the beginning of your topic title and click on the "Submit Modified Post" button. we will be grateful if you will follow these steps in the future, thanks 1 Link to comment Share on other sites More sharing options...
dhobo Posted May 30, 2013 Author Share Posted May 30, 2013 yeah I knew I had to do that, couldn't figure out exactly how it worked anymore. Thanks, will do that like this next time 1 Link to comment Share on other sites More sharing options...
larrypham Posted February 4, 2015 Share Posted February 4, 2015 Hi, I set 'tinymce' => true, as you did above but there was no editor. Please help. 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