Per inserire il compnente tinyMCE in un modulo di Prestashop (v1.6) ci sono due modi diversi:
- Utilizzando l’Helper Form di Prestashop:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$fields_form[0]['form'] = array ( 'input' => array ( array ( 'type' => 'textarea', 'label' => $this->l ( 'Your label:' ), 'name' => 'rich_text', 'autoload_rte' => true, 'required' => true, 'lang' => true, 'rows' => 10, 'cols' => 100, 'hint' => $this->l ( 'Invalid characters:' ).' <>;=#{}' ), **** $helper = new HelperForm (); **** $helper->generateForm ($fields_form); |
- Utilizzando Un template:
Per prima cosa definiamo il componente nella funzione getContent()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public function getContent() { $iso = $this->context->language->iso_code; $this->tpl_vars['iso'] = file_exists(_PS_CORE_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en'; $this->tpl_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_vars['ad'] = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_); $this->tpl_vars['tinymce'] = true; $this->context->controller->addJS(_PS_JS_DIR_.'tiny_mce/tiny_mce.js'); $this->context->controller->addJS(_PS_JS_DIR_.'admin/tinymce.inc.js'); ... ... return $this->smarty->fetch('yourtemplate.tpl'); } |
Poi creiamo il componente nel template smarty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<script type="text/javascript"> var iso = '{$iso|escape:'quotes':'UTF-8'}'; var pathCSS = '{$smarty.const._THEME_CSS_DIR_|escape:'quotes':'UTF-8'}'; var ad = '{$ad|escape:'quotes':'UTF-8'}'; $(document).ready(function(){ //Activate tinyMCE tinySetup({ editor_selector :"autoload_rte", relative_urls : false, plugins : "colorpicker link image paste pagebreak table contextmenu filemanager table code media autoresize textcolor fullpage", extended_valid_elements : "em[class|name|id],html,head" }); }); </script> <textarea name="content_html" class="rte autoload_rte rte autoload_rte">your text rich</textarea> |