eckeditor A CKEditor Extension for Yii

  1. Requirements
  2. Usage
  3. Resources
  4. Changelog
  5. Known Bugs
  6. Upcoming

This extension allows the use of CKEditor in forms. This widget uses CHtml:activeTextArea to create a text box, but also creates a CKEditor instance and then replaces the textbox with a CKEditor.

CKEditor v3.6.2 is included in the extension and is automagically published to the public assets folder with the assetManager included in Yii.

Requirements

This extension was created using Yii 1.1.9, but I would expect it to run on most 1.1 frameworks.

CKEditor v3.6.2 IS INCLUDED and is published to the public assets folder with the assets manager.

Usage

Installation

Use of this extension is simple. Simply unzip the extension and place the folder inside the extensions folder

/protected/extensions/

this will create a file structure as follows

/protected/extensions/ckeditor
/protected/extensions/ckeditor/ECKEditor.php <- Widget Class
/protected/extensions/ckeditor/ECKEdit5.php <- Standalone CKEditor Class
/protected/extensions/ckeditor/assets/* <- All the asset files for CKEditor
Usage in view

Replace any activeTextArea

<?php echo CHtml::activeTextArea($model,'content',array('rows'=>10, 'cols'=>70)); ?>

with this

<?php $this->widget('application.extensions.eckeditor.ECKEditor', array(
                'model'=>$model,
                'attribute'=>'content',
                )); ?>

if you want to use custom configure CKEditor to suit your taste, you can send in configuration information like this.

<?php $this->widget('application.extensions.eckeditor.ECKEditor', array(
                'model'=>$model,
                'attribute'=>'content',
                'config' => array(
                    'toolbar'=>array(
                        array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
                        array( 'Image', 'Link', 'Unlink', 'Anchor' ) ,
                    ),
                  ),
          
                )); ?>

In the code above, a custom toolbar is created that has the Source, Bold, Italic, etc controls enabled. You can pass almost any CKEditor configuration information via the config variable. To see all of how you can configure CKEditor visit: CKEditor Developer's Guide

Resources

I am not affiliated with CKEditor in any way, I have just adapted it's use to be easily used with Yii. This is a work in progress and your ideas/support would be greatly appreciated.

Many thanks to those at CKEditor

Changelog

v0.2 (Jan 23, 2012)
Added the ability to set CKEditor configuration
v0.1
Initial Release

Known Bugs

  • Generates - Not allowed to load local resource:<br/> file:///C:/xampp/htdocs/blog/protected/extensions/eckeditor/ECKEdit5.phpckeditor.js?t=B8DJ5M3 <br/>
  • Ajax validation doesn't work

Upcoming

  • Fix the javascript bug shown above.
  • Enable the ability for Ajax validation. Ajax validation doesn't work on this right now because the extension creates another instance with another id to create the editor. I'm not sure how to fix this yet, but I'll be working on this soon. Thanks to Sasha Kurylenko for pointing this out.
4 0
12 followers
5 587 downloads
Yii Version: 1.1
License: GPL-3.0
Category: User Interface
Developed by: polyhedron
Created on: Jan 23, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions