xywrbs 发表于 2011-12-21 20:33:40

codeigniter中集成百度的Ueditor

本帖最后由 xywrbs 于 2011-12-21 21:01 编辑

       百度出了一个Ueditor,比较有创意的一个东西,文档也很全,使用与集成简单,可扩展性强,我们也有了新的选择,不一定非得用FCK了。       根据官方教程,需要载入三个文件,分别是editor_config.js   editor_all.jsueditor.css,两个脚本,一个样式表。
       我们首先在CI目录下建立一个JS文件夹,用来存放js脚本,然后进入js文件夹,建立ueditor(当然,如果你愿意,你可以建立直接在CI目录下建立一个Ueditor文件夹),将http://ueditor.baidu.com下载的文件解压到ueditor文件夹中。
       然后进入controller目录,建立一个控制器,例如:
       <?php      class Test extends CI_Controller
      {
                function __construct()
                {
                        parent::__construct();
                        $this->load->helper('url');
                }

                function index()
                {
                        $this->load->view('ueditor');
                }       }
      ?>

       然后,进入view目录,建立一个ueditor.php文件,写入以下内容


<html>
<head>
<script type="text/javascript" src="<?php echo base_url();?>js/ueditor/editor_config.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/ueditor/editor_all.js"></script>
<link rel="stylesheet" href="<?php echo base_url();?>js/ueditor/themes/default/ueditor.css"/>
</head>
<body>
<div id="myEditor"></div>
<script type="text/javascript">
      var editor = new baidu.editor.ui.Editor();
      editor.render("myEditor");
</script>
</body>
</html>

      这里需要注意的主要是三点:
            1.不要忘记载入url辅助函数
            2.注意udeitor编辑器存放的位置
            3.不要打错字~O(∩_∩)O~(我就是因为将default打成了defautl搞得显示不出样式,最后firebug看了一下才知道)


lzw等待 发表于 2014-10-28 19:12:04

我按照楼主的方法写,可是试图页面啥都没有!刚刚学ci   麻烦各位大神指点

censtart 发表于 2016-3-26 10:31:31

按照要求配置了。里面都是空白的。是不是编辑器的版本已经不适合这样的调用方法了?

afterninty 发表于 2016-4-20 10:35:31

切记config.js一定要在all.js文件前面,否则显示不出来

a123123 发表于 2011-12-21 23:08:45

不错,支持{:soso_e179:}

wangjin 发表于 2011-12-21 23:39:07

:L:L:L:L

xiehao 发表于 2011-12-22 09:38:19

路径不知道怎么设置,设置格式的那些对话框显示404错误

xiehao 发表于 2011-12-23 09:59:18

上传图片的那里,弹出的对话框是404,应该怎么设置路径才能成功?

xywrbs 发表于 2011-12-24 21:02:35

xiehao 发表于 2011-12-23 09:59 static/image/common/back.gif
上传图片的那里,弹出的对话框是404,应该怎么设置路径才能成功?

修改ueditor/ueditor_config.js文件,修改这一行为'insertimage': "http://127.0.0.1/tblog/dialogs/image/image.html",(添上绝对路径)

sdink 发表于 2011-12-25 01:51:02

xywrbs 发表于 2011-12-24 21:02 static/image/common/back.gif
修改ueditor/ueditor_config.js文件,修改这一行为'insertimage': "http://127.0.0.1/tblog/dialogs/imag ...

dialogs/image/image.html   304行   上传处理页面的url地址 可以来个绝对路径

niki090 发表于 2012-1-2 01:03:18

:victory::victory::victory:

低调man 发表于 2012-1-13 12:15:17

百度的编辑器这个功能如何,有没有文件上传接口

longjianghu 发表于 2012-1-13 14:21:24

低调man 发表于 2012-1-13 12:15 static/image/common/back.gif
百度的编辑器这个功能如何,有没有文件上传接口

下载包里就有
页: [1] 2 3
查看完整版本: codeigniter中集成百度的Ueditor