Home  >  Article  >  Backend Development  >  Tutorial on integrating CKEditor editor in CI framework_PHP tutorial

Tutorial on integrating CKEditor editor in CI framework_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:28:47800browse

1. Place the fckeditor directory into CI_PATH/system/plugins/

2. Add:

to CI_PATH/system/application/config/config.php

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

3. Create a helper and create a new form_helper.php in /system/application/helpers

Copy code The code is as follows:

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( is_array ($data) )
                                                                                                                 ( isset($data['basepath']) )
           $fckeditor->BasePath = $data['basepath'];
                                                fckeditor->ToolbarSet = $data['toolbarset'];
                                                                                       ​> ISSET ($ data ['height']))
$ fckeditor- & gt; height = $ data ['height'];
}
Return $ fcKeditor- & gt; Createhtml ();
}
else
{
return form_textarea( $data, $value, $extra );
}
}
?>




4. Use fckeditor in the project




Copy code

The code is as follows:

$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 );
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/781029.htmlTechArticle1. Place the fckeditor directory into CI_PATH/system/plugins/ 2. In CI_PATH/system/application/config/ Add to config.php: $config['fckeditor_basepath'] = "/system/plugins/fckeditor/"; $c...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn