Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 15 revisions

Please find below the first release of my [url=http://www.kromack.com/codeigniter/ckeditor-helper-for-codeigniter/]CKEditor Helper for CodeIgniter[/url].

This helper can, for the moment, manage all CKEditor’s available configuration options and custom styles definitions.

The first step is to download the CKEditor editor package, note that the helper have only be tested over CKEditor 3.0.2.

Place the entire ckeditor folder into the CodeIgniter’s system/plugins folder.

Download and place the ckeditor_helper.php file into the CodeIgniter’s system/application/helpers folder.

File:CKEditor.zip

[h3]The controller[/h3] [code] <?php

class CKEditor extends Controller {

public $data     =     array();

public function __construct() {

    parent::Controller();

    $this->load->helper('url'); //You should autoload this one ;)
    $this->load->helper('ckeditor');

    //Ckeditor's configuration
    $this->data['ckeditor'] = array(

        //ID of the textarea that will be replaced
        'id' => 'contenu',

        //Optionnal values
        'config' => array(
            'toolbar'     =>     "Full",     //Using the Full toolbar
            'width'     =>     "550px",    //Setting a custom width
            'height'     =>     '100px',    //Setting a custom height

        ),

        //Replacing styles from the "Styles tool"
        'styles' => array(

            //Creating a new style named "style 1"
            'style 1' => array (
                'name'         =>     'Blue Title',
                'element'     =>     'h2',
                'styles' => array(
                    'color'             =>     'Blue',
                    'font-weight'         =>     'bold'
                )
            ),

            //Creating a new style named "style 2"
            'style 2' => array (
                'name'         =>     'Red Title',
                'element'     =>     'h2',
                'styles' => array(
                    'color'             =>     'Red',
                    'font-weight'         =>     'bold',
                    'text-decoration'    =>     'underline'
                )
            )                
        )
    );

    $this->load->view('ckeditor', $this->data);
}

} [/code]

[h3]The view[/h3] [code] <textarea name="content" id="content" ><p>Example data

</textarea> <?php echo display_ckeditor($ckeditor); ?> [/code]

[url=http://www.kromack.com/codeigniter/ckeditor-helper-for-codeigniter/]View the full tutorial[/url].

Clone this wiki locally