Tutorial _php tutorial on integrating CKEditor Editor in CI framework

Source: Internet
Author: User
1. Place the FCKeditor directory in the ci_path/system/plugins/

2. Add in ci_path/system/application/config/config.php:

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

3, create helper, new form_helper.php in/system/application/helpers

Copy CodeThe 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 ($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, the use of FCKeditor in the project

Copy the Code code 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);
?>

http://www.bkjia.com/PHPjc/781029.html www.bkjia.com true http://www.bkjia.com/PHPjc/781029.html techarticle 1, the FCKeditor directory into the CI_PATH/SYSTEM/PLUGINS/2, added in ci_path/system/application/config/config.php: $config [' Fckeditor_basepath '] = "/system/plugins/fckeditor/"; $c ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.