在CodeIgniter中实现TinyMCE的问题
我正在尝试在CodeIgniter中实现TinyMCE。 我创建了一个视图文件,并从控制器中调用它。 我已将所有文件上传到我的CI项目文件夹中,并显示了文件的路径。 但它没有用。 这是视图文件:
Full featured example <script type="text/javascript" src="application/tinymce/jscripts/tiny_mce/tiny_mce.js"> tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "autolink,lists,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,wordcount,advlist,autosave,visualblocks", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "application/tinymce/examples/css/content.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "application/tinymce/examples/lists/template_list.js", external_link_list_url : "application/tinymce/examples/lists/link_list.js", external_image_list_url : "application/tinymce/examples/lists/image_list.js", media_external_list_url : "application/tinymce/examples/lists/media_list.js", // Style formats style_formats : [ {title : 'Bold text', inline : 'b'}, {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}}, {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}}, {title : 'Example 1', inline : 'span', classes : 'example1'}, {title : 'Example 2', inline : 'span', classes : 'example2'}, {title : 'Table styles'}, {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'} ], // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } });
您不能在application
文件夹中调用文件 ,请查看应用程序中存在的.htaccess
文件:
Deny from all
你将获得403错误Access forbidden!
无论如何,这个问题不会通过禁用该行来解决,因为CodeIgniter查看URI并说:“好的,我应该调用存在于controller文件夹中的application
类,然后通过传递这些参数来调用tinymce
方法: jscripts, tiny_mce, tiny_mce.js
“。
所以:
- 将文件放在
application/
文件夹之外,比如index.php
旁边的public/
folder。 - 打开存在于根目录中的
.htaccess
文件,并添加文件/文件夹的名称以防止它们通过index.php
传递。
例如,考虑这个结构:
system/ application/ public/ img/ css/ js/ .htaccess index.php robots.txt
重写规则( .htaccess
)应该是:
RewriteEngine on RewriteCond $1 !^(index\.php|public|robots\.txt) # | # Exclude the public folder <-- # From being treated by: RewriteRule ^(.*)$ index.php/$1 [L]
有关详细信息,请参阅CodeIgniter用户指南 。
请确保项目中没有js错误,并且与编辑器相关的js路径也是正确的,因此js可以用于编辑器。