TP6框架中引用KindEditor编辑器

一个管理后台,基本上离不开富文本编辑器的使用。下面说下TP6里面引用 kindeditor的方法

1、下载kindeditor 放到目录 /public/admin 下面

2、前端代码

 1 html:
 2 <textarea placeholder="请输入内容" id="news_content" name="news_content" class="layui-textarea" style="700px;height:400px;">
 3 {:htmlspecialchars_decode($info.news_content)}
 4 </textarea>
 5 
 6 JS:
 7 <script charset="utf-8" src="/admin//kindeditor/kindeditor-all-min.js"></script>
 8 <script charset="utf-8" src="/admin/kindeditor/lang/zh-CN.js"></script>
 9 <script>
10         var editor;
11         KindEditor.ready(function(K) {
12             editor =  K.create('#news_content', {
13                  uploadJson : '/admin/kindeditor/php/upload_json.php',
14                  fileManagerJson : '/admin/kindeditor/php/file_manager_json.php',
15                 allowFileManager : true
16             });
17         });
18 </script>

3、富文本编辑器用到的是 kindeditor ,使用TP的话,需要配置下伪静态 ,不然无法上传图片和文件

nginx下面的配置

1 location / {
2     if (!-e $request_filename) {
3     rewrite ^/admin/kindeditor/(.*)$ /admin/kindeditor/$1 last;
4     rewrite ^(.*)$ /index.php?s=/$1 last;
5     }
6 }

作用是:访问 /admin/kindeditor里面的文件的时候,避免通过tp的默认路由访问到其他地方

原文地址:https://www.cnblogs.com/ypeih/p/15470221.html