Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Tinymce动态生成的图标列表_Php_Jquery_Tinymce_Document - Fatal编程技术网

Php Tinymce动态生成的图标列表

Php Tinymce动态生成的图标列表,php,jquery,tinymce,document,Php,Jquery,Tinymce,Document,我正在尝试为tiny mce创建动态生成的图标列表。我已经编写了所有相关的php函数,我通过以下代码调用该函数 $.post(url_file, { content_name: $class_name, page_url: filePath, app_code: app_code }, function(data){ var buttonlist = data; }); 我需要传递以上3个参数才能得到这些图标。现在我

我正在尝试为tiny mce创建动态生成的图标列表。我已经编写了所有相关的php函数,我通过以下代码调用该函数

$.post(url_file, { 
       content_name: $class_name, 
       page_url: filePath,
       app_code: app_code
   },
   function(data){
       var buttonlist = data;
   });
我需要传递以上3个参数才能得到这些图标。现在我有了
按钮列表
。我尝试了
document.write(buttonlist)
,但它给了我
missing:after属性id
错误。 我试着把它印在纸上

tinyMCE.init({
        mode : "exact",
        elements : "elm1", 
        theme : "advanced",
        plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,
                   style,layer,table,save,advhr,advimage,advlink,
                   emotions,iespell,inlinepopups,insertdatetime,preview,
                   media,searchreplace,print,contextmenu,paste,
                   directionality,fullscreen,noneditable,visualchars,nonbreaking,
                   xhtmlxtras,template",
    --> document.write(buttonlist);
        theme_advanced_toolbar_location : "top",
您知道如何在tinymce代码中打印此值吗?
非常感谢你的帮助

当使用php创建页面时,php代码首先被执行,然后页面被转移到客户端。因此,您可以执行以下操作:

<?php
    $my_generated_buttonlist = '"bold, italic, underline"';
?>

tinyMCE.init({

    mode : "exact",

    elements : "elm1", 

    theme : "advanced",

    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

    theme_advanced_buttons1: '<?php echo $my_generated_buttonlist; ?>',

    theme_advanced_toolbar_location : "top",
    ...

tinyMCE.init({
模式:“精确”,
元素:“elm1”,
主题:“高级”,
插件:“Archiv、pagebreak、safari、拼写检查器、pagebreak、样式、图层、表格、保存、advhr、advimage、advlink、情感、iSpell、inlinepopups、insertdatetime、预览、媒体、searchreplace、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、visualchars、不可中断、xhtmlxtras、模板”,
主题\高级\按钮1:“”,
主题\高级\工具栏\位置:“顶部”,
...

使用php创建页面时,在将页面移交给客户端之前,首先执行php代码。因此,您可以执行以下操作:

<?php
    $my_generated_buttonlist = '"bold, italic, underline"';
?>

tinyMCE.init({

    mode : "exact",

    elements : "elm1", 

    theme : "advanced",

    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

    theme_advanced_buttons1: '<?php echo $my_generated_buttonlist; ?>',

    theme_advanced_toolbar_location : "top",
    ...

tinyMCE.init({
模式:“精确”,
元素:“elm1”,
主题:“高级”,
插件:“Archiv、pagebreak、safari、拼写检查器、pagebreak、样式、图层、表格、保存、advhr、advimage、advlink、情感、iSpell、inlinepopups、insertdatetime、预览、媒体、searchreplace、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、visualchars、不可中断、xhtmlxtras、模板”,
主题\高级\按钮1:“”,
主题\高级\工具栏\位置:“顶部”,
...

您需要动态添加按钮,对吗

试试这个:

要获得它,请对每个按钮行使用json:

$.post(url_file, { 
   content_name: $class_name, 
   page_url: filePath,
   app_code: app_code
},
function(data){
   var buttons = $.parseJSON(data)
   var buttonlist1 = buttons.line1;
   var buttonlist2 = buttons.line2;
   var buttonlist3 = buttons.line3;
});
然后,对于MCE初始化:

tinyMCE.init({
    mode : "exact",
    elements : "elm1", 
    theme : "advanced",
    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,
               style,layer,table,save,advhr,advimage,advlink,
               emotions,iespell,inlinepopups,insertdatetime,preview,
               media,searchreplace,print,contextmenu,paste,
               directionality,fullscreen,noneditable,visualchars,nonbreaking,
               xhtmlxtras,template",
--> theme_advanced_buttons1 : buttonlist1,
--> theme_advanced_buttons2 : buttonlist2,
--> theme_advanced_buttons3 : buttonlist3,
    theme_advanced_toolbar_location : "top",

您需要动态添加按钮,对吗

试试这个:

要获得它,请对每个按钮行使用json:

$.post(url_file, { 
   content_name: $class_name, 
   page_url: filePath,
   app_code: app_code
},
function(data){
   var buttons = $.parseJSON(data)
   var buttonlist1 = buttons.line1;
   var buttonlist2 = buttons.line2;
   var buttonlist3 = buttons.line3;
});
然后,对于MCE初始化:

tinyMCE.init({
    mode : "exact",
    elements : "elm1", 
    theme : "advanced",
    plugins : "Archiv,pagebreak,safari,spellchecker,pagebreak,
               style,layer,table,save,advhr,advimage,advlink,
               emotions,iespell,inlinepopups,insertdatetime,preview,
               media,searchreplace,print,contextmenu,paste,
               directionality,fullscreen,noneditable,visualchars,nonbreaking,
               xhtmlxtras,template",
--> theme_advanced_buttons1 : buttonlist1,
--> theme_advanced_buttons2 : buttonlist2,
--> theme_advanced_buttons3 : buttonlist3,
    theme_advanced_toolbar_location : "top",

我无法将我的值输入到php变量中,这就是为什么我一直坚持这样做的原因。我从数据库中获取这些图标,所以我必须查询它,我的php函数在查询后生成这些图标列表。但要查询它,我需要将我传递的变量传递到$.post。好吧,假设我解决了这个问题,我只有一个解决方案,我将内容写入了一个文件和回显文件内容。但我有另一个问题。我在一个文件中有几个不同的文本区域,我想在每个tinymce实例上显示不同的图标。当我使用我的解决方案时,它总是加载它加载的第一个。很明显。你有什么解决方案吗?我无法将我的值放入php变量,这就是为什么我坚持使用这个。im getti从数据库中删除这些图标,所以我必须查询它,我的php函数在查询后生成这些图标列表。但要查询它,我需要将我传递给$.post的变量传递给$.post。好吧,假设我解决了这个问题,我只有一个解决方案,我将内容写入文件并回显文件内容。但我还有一个问题。我在一个文件,我想在每个tinymce实例上显示不同的图标。当我使用我的解决方案时,它总是加载它加载的第一个。很明显..有什么解决方案吗?您好,谢谢您的回答。我尝试了。但是tinymce没有加载,一定是出了问题。但是我没有看到json数据有任何问题。当我
alert(buttonlist2);
它提醒正确的图标。哈哈哈!它成功了!我把
tinyMCE.init()
放在
函数(数据){
里面,谢谢你的回答!你好,谢谢你的回答。我试过了。但是tinyMCE没有加载肯定是出了什么问题。但是我没有看到json数据有任何问题。当我
提醒(buttonlist2)时
它提醒正确的图标。啊哈哈!它成功了!我把
tinyMCE.init()
放在
函数(数据){
里面,谢谢你!