Php 在启动前,直接从Smarty模板使用tinymce

Php 在启动前,直接从Smarty模板使用tinymce,php,tinymce,smarty,prestashop,prestashop-1.6,Php,Tinymce,Smarty,Prestashop,Prestashop 1.6,我正在做一个预启动模块。此模块将锚定到名为“hookDisplayAdminProductsExtra”的挂钩上 我需要使用库中的TEXTAREA字段tinymce,您可以直接从Smarty创建TEXTAREA,而不是作为控制器?可能使用jQuery函数或向字段添加类 我在tpl文件中的代码是: {foreach $row_list as $row} <textarea id="description_1" name="description_1" class="autoload_

我正在做一个预启动模块。此模块将锚定到名为“hookDisplayAdminProductsExtra”的挂钩上

我需要使用库中的TEXTAREA字段tinymce,您可以直接从Smarty创建TEXTAREA,而不是作为控制器?可能使用jQuery函数或向字段添加类

我在tpl文件中的代码是:

{foreach $row_list as $row}
    <textarea id="description_1" name="description_1" class="autoload_rte" aria-hidden="true">
        {$row['desc']}
    </textarea>
{/foreach}
当Prestashop通过以下方式加载选项卡信息时,“使用”自动加载rte:

$(document).ready(function(){

    // Execute when tab Informations has finished loading
    tabs_manager.onLoad('Informations', function(){
        tinySetup({
            editor_selector :"autoload_rte",
            setup : function(ed) {
                ed.on('init', function(ed)
                {
                    if (typeof ProductMultishop.load_tinymce[ed.target.id] != 'undefined')
                    {
                        if (typeof ProductMultishop.load_tinymce[ed.target.id])
                            tinyMCE.get(ed.target.id).hide();
                        else
                            tinyMCE.get(ed.target.id).show();
                    }
                });

                ed.on('keydown', function(ed, e) {
                    tinyMCE.triggerSave();
                    textarea = $('#'+tinymce.activeEditor.id);
                    var max = textarea.parent('div').find('span.counter').data('max');
                    if (max != 'none')
                    {
                        count = tinyMCE.activeEditor.getBody().textContent.length;
                        rest = max - count;
                        if (rest < 0)
                            textarea.parent('div').find('span.counter').html('<span style="color:red;">Maximum '+ max +' characters : '+rest+'</span>');
                        else
                            textarea.parent('div').find('span.counter').html(' ');
                    }
                });
            }
        });
    });

});
$(文档).ready(函数(){
//当选项卡信息完成加载时执行
tabs\u manager.onLoad('Informations',function(){
tinySetup({
编辑器选择器:“自动加载”,
设置:功能(ed){
ed.on('init',函数(ed)
{
if(ProductMultishop.load的类型_tinymce[ed.target.id]!=“未定义”)
{
if(ProductMultishop.load的类型\u tinymce[ed.target.id])
tinyMCE.get(ed.target.id).hide();
其他的
tinyMCE.get(ed.target.id).show();
}
});
ed.on('keydown',功能(ed,e){
tinyMCE.triggerSave();
textarea=$(“#”+tinymce.activeEditor.id);
var max=textarea.parent('div')。find('span.counter')。data('max');
如果(最大!=“无”)
{
count=tinyMCE.activeEditor.getBody().textContent.length;
剩余=最大计数;
如果(剩余<0)
textarea.parent('div').find('span.counter').html('Maximum'+max+'字符:'+rest+'');
其他的
textarea.parent('div').find('span.counter').html(“”);
}
});
}
});
});
});
除此之外,其他选项卡的加载也晚于信息选项卡。要解决这个问题,需要初始化所需字段的tinymce。选择另一个选择器(不确定是否需要,但至少100%不可能与当前选择器混淆),例如mytextarea类,然后使用:

<script>$(document).ready(function(){tinymce.init({mode : "textareas", editor_selector : "mytextarea", plugins: "textcolor paste code"});})</script>
$(document).ready(函数(){tinymce.init({模式:“textareas”,编辑器_选择器:“mytextarea”,插件:“textcolor粘贴代码”});})
这可以在你的第三方物流。 在我的测试中,如果没有插件设置,控制台日志中就会出现错误。但您可以根据需要调整tinymce设置。

当Prestashop使用以下方式加载选项卡信息时,自动加载rte被“使用”:

$(document).ready(function(){

    // Execute when tab Informations has finished loading
    tabs_manager.onLoad('Informations', function(){
        tinySetup({
            editor_selector :"autoload_rte",
            setup : function(ed) {
                ed.on('init', function(ed)
                {
                    if (typeof ProductMultishop.load_tinymce[ed.target.id] != 'undefined')
                    {
                        if (typeof ProductMultishop.load_tinymce[ed.target.id])
                            tinyMCE.get(ed.target.id).hide();
                        else
                            tinyMCE.get(ed.target.id).show();
                    }
                });

                ed.on('keydown', function(ed, e) {
                    tinyMCE.triggerSave();
                    textarea = $('#'+tinymce.activeEditor.id);
                    var max = textarea.parent('div').find('span.counter').data('max');
                    if (max != 'none')
                    {
                        count = tinyMCE.activeEditor.getBody().textContent.length;
                        rest = max - count;
                        if (rest < 0)
                            textarea.parent('div').find('span.counter').html('<span style="color:red;">Maximum '+ max +' characters : '+rest+'</span>');
                        else
                            textarea.parent('div').find('span.counter').html(' ');
                    }
                });
            }
        });
    });

});
$(文档).ready(函数(){
//当选项卡信息完成加载时执行
tabs\u manager.onLoad('Informations',function(){
tinySetup({
编辑器选择器:“自动加载”,
设置:功能(ed){
ed.on('init',函数(ed)
{
if(ProductMultishop.load的类型_tinymce[ed.target.id]!=“未定义”)
{
if(ProductMultishop.load的类型\u tinymce[ed.target.id])
tinyMCE.get(ed.target.id).hide();
其他的
tinyMCE.get(ed.target.id).show();
}
});
ed.on('keydown',功能(ed,e){
tinyMCE.triggerSave();
textarea=$(“#”+tinymce.activeEditor.id);
var max=textarea.parent('div')。find('span.counter')。data('max');
如果(最大!=“无”)
{
count=tinyMCE.activeEditor.getBody().textContent.length;
剩余=最大计数;
如果(剩余<0)
textarea.parent('div').find('span.counter').html('Maximum'+max+'字符:'+rest+'');
其他的
textarea.parent('div').find('span.counter').html(“”);
}
});
}
});
});
});
除此之外,其他选项卡的加载也晚于信息选项卡。要解决这个问题,需要初始化所需字段的tinymce。选择另一个选择器(不确定是否需要,但至少100%不可能与当前选择器混淆),例如mytextarea类,然后使用:

<script>$(document).ready(function(){tinymce.init({mode : "textareas", editor_selector : "mytextarea", plugins: "textcolor paste code"});})</script>
$(document).ready(函数(){tinymce.init({模式:“textareas”,编辑器_选择器:“mytextarea”,插件:“textcolor粘贴代码”});})
这可以在你的第三方物流。 在我的测试中,如果没有插件设置,控制台日志中就会出现错误。但您可以根据需要调整tinymce设置