CI框架中集成CKEditor编辑器的教程
2015-01-24信息快讯网
CKEditor是在很多开发过程中都会用到的一个富文本编辑器,那么如何在CI框架中使用它呢?这里介绍了在CI下使用CKEditor的方法,版本比较低,是在CI 1.7.3下使用fckeditor 2.6.6。供大家参考。
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 );
?>
Codeigniter(CI)框架分页函数及相关知识
用 Composer构建自己的 PHP 框架之使用 ORM
ThinkPHP做文字水印时提示call an undefined function exif_imagetype()解决方法
thinkphp视图模型查询提示ERR: 1146:Table 'db.pr_order_view' doesn't exist的解决方法
仿dedecms下拉分页样式修改的thinkphp分页类实例
PHPUnit安装及使用示例
Smarty中调用FCKeditor的方法
Windows下安装PHP单元测试环境PHPUnit图文教程
ThinkPHP整合百度Ueditor图文教程
php中spl_autoload详解
Linux下安装oracle客户端并配置php5.3
PHP的mysqli_query参数MYSQLI_STORE_RESULT和MYSQLI_USE_RESULT的区别
安装ImageMagick出现error while loading shared libraries的解决方法
PHP中auto_prepend_file与auto_append_file用法实例分析
CI(CodeIgniter)框架介绍
PHP小教程之实现链表
PHP的foreach中使用引用时需要注意的一个问题和解决方法
windwos下使用php连接oracle数据库的过程分享
PhpDocumentor 2安装以及生成API文档的方法
dedecms函数分享之获取某一栏目所有子栏目
PHP 之 写时复制介绍(Copy On Write)
PHP中copy on write写时复制机制介绍
PHP中spl_autoload_register()和__autoload()区别分析
PHP异常Parse error: syntax error, unexpected T_VAR错误解决方法
codeigniter框架The URI you submitted has disallowed characters错误解决方法
php加速器eAccelerator的配置参数、API详解
PHP FATAL ERROR: CALL TO UNDEFINED FUNCTION BCMUL()解决办法
PHP_NETWORK_GETADDRESSES: GETADDRINFO FAILED问题解决办法
Fatal error: session_start(): Failed to initialize storage module: files问题解决方法
CodeIgniter框架提示Disallowed Key Characters的解决办法