将WYSIWYG编辑器添加到Prestashop 1.6.X模块智能模板表单中

时间:2016-01-05 03:38:36

标签: smarty prestashop-1.6 bootstrap-wysiwyg

我正在Prestashop 1.6.X中做一个自定义模块。在我的模块中,我有一个巧妙的形式。我想以这种聪明的形式添加WYSIWYG编辑器。那么有人能告诉我如何将WYSIWYG编辑器添加到智能模板表单中吗?任何帮助或建议都会非常明显。感谢

1 个答案:

答案 0 :(得分:6)

你有很多解决方案来表明你的表单中的元素是否具有所见即所得的编辑器。如果您使用helperform,则可以使用此解决方案:

解决方案后台/使用帮助表格

$fields_form[0]['form'] = array (
            'input' => array (
                array (
                    'type' => 'textarea',
                    'label' => $this->l ( 'Your field:' ),
                    'name' => 'pdf_content',
                    'autoload_rte' => true,
                    'required' => true,
                    'lang' => true,
                    'rows' => 10,
                    'cols' => 100,
                    'hint' => $this->l ( 'Invalid characters:' ).' <>;=#{}'
                ),
****
$helper = new HelperForm ();
****
$helper->generateForm ( $fields_form )

模板中的第二个解决方案:

yourmodule.php函数中的示例getContent

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');
智能模板文件中的

<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(){


            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>