CI框架中集成CKEditor编辑器的教程

1、将fckeditor目录置入CI_PATH/system/plugins/

2、在CI_PATH/system/application/config/config.php中加入:

$config['fckeditor_basepath'] = "/system/plugins/fckeditor/";
$config['fckeditor_toolbarset_default'] = 'Default';

3、创建helper,在/system/application/helpers新建form_helper.php

代码如下:

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
include_once( BASEPATH . '/helpers/form_helper'.EXT);
function form_fckeditor($data = '', $value = '', $extra = '')
{
     $CI =& get_instance();
    $fckeditor_basepath = $CI->config->item('fckeditor_basepath');
     require_once( $_SERVER["DOCUMENT_ROOT"] . $fckeditor_basepath. 'fckeditor.php' );
    $instanceName = ( is_array($data) && isset($data['name'])   ) ? $data['name'] : $data;
    $fckeditor = new FCKeditor($instanceName);
     if( $fckeditor->IsCompatible() )
    {
         $fckeditor->Value = html_entity_decode($value);
        $fckeditor->BasePath = $fckeditor_basepath;
         if( $fckeditor_toolbarset = $CI->config->item('fckeditor_toolbarset_default'))
                $fckeditor->ToolbarSet = $fckeditor_toolbarset;
         if( is_array($data) )
        {
            if( isset($data['value']) )
                $fckeditor->Value = html_entity_decode($data['value']);
             if( isset($data['basepath']) )
                $fckeditor->BasePath = $data['basepath'];
             if( isset($data['toolbarset']) )
                $fckeditor->ToolbarSet = $data['toolbarset'];
             if( isset($data['width']) )
                $fckeditor->Width = $data['width'];
             if( isset($data['height']) )
                $fckeditor->Height = $data['height'];
        }
        return $fckeditor->CreateHtml();
    }
    else
    {
        return form_textarea( $data, $value, $extra );
    }
}
?>

4、在项目中使用fckeditor

代码如下:

<?php
$this->load->helper('form_helper');
$data = array(
    'name'        => 'newsContent',
    'id'          => 'newsContent',
    //'toolbarset'  => 'Advanced',
    'basepath'    => $this->config->item('fckeditor_basepath'),
    'width'       => '80%',
    'height'      => '200'
);
echo form_fckeditor( $data );
?>

(0)

相关推荐

  • yii,CI,yaf框架+smarty模板使用方法

    本文实例讲述了yii,CI,yaf框架+smarty模板使用方法.分享给大家供大家参考,具体如下: 最近折腾了框架的性能测试,其中需要测试各个模板跟smarty配合的性能,所以折腾了一桶,现总结一下.之前已经写过kohana框架+smarty模板,这里不再重复了. 一.yii框架+smarty模板 yii是覆盖了viewRenderer组件. 1.1,下载yii框架并解压,下载smarty框架并解压,将smarty/libs文件夹拷到yii框架application/protected/vend

  • CI框架集成Smarty的方法分析

    本文实例讲述了CI框架集成Smarty的方法.分享给大家供大家参考,具体如下: 因为CI自带的模板功能不是很方便,所以大家普遍采用集成Smarty的方式来弥补CI这方面的不足. 本人在网上看了不少CI集成Smarty的教程,包括咱们CI论坛里面的一个精华帖子 http://codeigniter.org.cn/forums/forum.php?mod=viewthread&tid=10345. 自己对比了一下这些教程,我认为下面这个方案是所有里面最优秀的,强烈推荐给大家(当然也是我自己采取的方案

  • codeigniter集成ucenter1.6双向通信的解决办法

    用codeigniter开发一个子网站,之后想和原来的论坛进行同步,包括同步登陆和双向通信 先装好ucenter,然后新建一个other的应用,把生成的代码拷出来,新建一个config.ini.php到你的uc_client,ucenter会产生一个yourdomain.com/api/uc.php的请求,/api/uc.php不需要填写,要保证ucenter请求正确位置,才能做到双向通信 把uc_client复制到你的网站,目录可以自己定,就根目录吧.如果你把api目录放到uc_client目

  • CI框架整合smarty步骤详解

    本文详细讲述了CI框架整合smarty步骤.分享给大家供大家参考,具体如下: Ci结合smarty的配置步骤: 1. 第一步配置ci和下载smarty的模板个人喜欢用(Smarty-3.1.8)这个版本. 2. 第二部把下载到的smarty版本解压然后把里面的libs文件改名为smarty然后把这个文件拷到ci\application\libraries目录下面 3. 在ci\application\libraries这个目录下面建立一个文件,文件名可以自定义,例如见一个tp.php的文档. 4

  • CodeIgniter中使用Smarty3基本配置

    一.创建Smarty类库 1.将smarty的libs文件复制到libraries下(这里我重命名为smarty) 2.新建Cismarty.php文件.(符合文件规范,文件名的首字母和class名的首字母大写,但是控制器引用加载时,类名/文件名不需要大写) Cismarty.php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require(APPPATH . 'libraries/smart

  • Codeigniter中集成smarty和adodb的方法

    本文实例讲述了Codeigniter中集成smarty和adodb的方法.分享给大家供大家参考,具体如下: 在CodeIgniter中要写自己的库,就需要写两个文件,一个是在application/init下面的init_myclass.php文件(如果没有init目录,自己创建).另外一个就是在application/libraries目录下创建myclass.php文件. 这里myclass是你的类名.一些规则大家看手册就好了,我这里直接就说步骤了. 1)在application/libra

  • CI框架中集成CKEditor编辑器的教程

    1.将fckeditor目录置入CI_PATH/system/plugins/ 2.在CI_PATH/system/application/config/config.php中加入: $config['fckeditor_basepath'] = "/system/plugins/fckeditor/"; $config['fckeditor_toolbarset_default'] = 'Default'; 3.创建helper,在/system/application/helper

  • Python的Flask框架中集成CKeditor富文本编辑器的教程

    CKeditor是目前最优秀的可见即可得网页编辑器之一,它采用JavaScript编写.具备功能强大.配置容易.跨浏览器.支持多种编程语言.开源等特点.它非常流行,互联网上很容易找到相关技术文档,国内许多WEB项目和大型网站均采用了CKeditor. 下载CKeditor 访问CKeditor官方网站,进入下载页面,选择Standard Package(一般情况下功能足够用了),然后点击Download CKEditor按钮下载ZIP格式的安装文件.如果你想尝试更多的功能,可以选择下载Full

  • Thinkphp5框架中引入Markdown编辑器操作示例

    本文实例讲述了Thinkphp5框架中引入Markdown编辑器操作.分享给大家供大家参考,具体如下: 编辑器下载地址以及演示:https://pandao.github.io/editor.md/ 1.把下载的项目放在public目录下 2.页面中引入jquery.js,editormd.js,editormd.css demo <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu

  • CI框架中数据库操作函数$this->db->where()相关用法总结

    本文实例总结了CI框架中数据库操作函数$this->db->where()相关用法.分享给大家供大家参考,具体如下: CI 框架数据库操作函数 this->db->where() 的使用 1) $this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE) 如果把$this->db->where() 接受可选的第三个参数设置为 FALSE, CodeIgniter 将不会为

  • CI框架中$this->load->library()用法分析

    本文分析了CI框架中$this->load->library()的用法.分享给大家供大家参考,具体如下: 我第一次加载失败,原来是文件名和类名不同的原因,先总结关于CI加载你自己的类文件注意事项: 1.第三方加载文件应放在application/libraries文件下 2.文件名和类名应该相同,并且首字母大写,比如说文件名Excel.php  类名应该为Excel 3.通过:$this->load->library('类');方式在你需要的地方加载 4.也可以在applicati

  • CI框架中redis缓存相关操作文件示例代码

    本文实例讲述了CI框架中redis缓存相关操作文件.分享给大家供大家参考,具体如下: redis缓存类文件位置: 'ci\system\libraries\Cache\drivers\Cache_redis.php' <?php /** * CodeIgniter * * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * * Licensed under

  • CI框架中cookie的操作方法分析

    本文实例讲述了CI框架中cookie的操作方法.分享给大家供大家参考.具体分析如下: 第一种设置cookie的方式:采用php原生态的方法设置的cookie的值 复制代码 代码如下: setcookie("user_id",$user_info['user_id'],86500);  setcookie("username",$user_info['username'],86500);  setcookie("password",$user_in

  • CI框架中site_url()和base_url()的区别

    在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url()和base_url()很容易混淆,下面来说说他们的区别! 假如你config文件里面的base_url和index_page是这样定义的: config['base_url'] = "http://domain.com/"; config['index_page'] = "index.php"; 那么你若使用site_url("news/php/2");则实际url为 http

  • Laravel框架中集成MongoDB和使用详解

    * 推荐组件 composer require jenssegers/mongodb ^3.3 -vvv(本人的laravel版本是5.5) 修改config/app.php * 注册服务 Jenssegers\Mongodb\MongodbServiceProvider::class, * 添加 Facades 'Mongo' => Jenssegers\Mongodb\MongodbServiceProvider::class, * 修改数据库配置文件 config/database.php

  • 详解在YII2框架中使用UEditor编辑器发布文章

    本文介绍了详解在YII2框架中使用UEditor编辑器发布文章 ,分享给大家,具体如下: 创建文章数据表 文章数据表主要有4个字段 1.id  主键(int) 2.title 标题(varchar) 3.content 内容(text) 4.created_time 创建时间(int) 创建文章模型 创建文章模型,不要忘记设置验证规则和字段的名称 namespace backend\models; class Article extends \yii\db\ActiveRecord { publ

随机推荐