PHPackages                             maxwen/yii2-ckeditor-widget - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. maxwen/yii2-ckeditor-widget

ActiveExtension[Framework](/categories/framework)

maxwen/yii2-ckeditor-widget
===========================

ckeditor widget for yii2 framework, with ckfinder intergrated

1.0.9(9y ago)4429MITJavaScript

Since Sep 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/max-wen/yii2-ckeditor-widget)[ Packagist](https://packagist.org/packages/maxwen/yii2-ckeditor-widget)[ RSS](/packages/maxwen-yii2-ckeditor-widget/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (12)Used By (0)

yii2-ckeditor-widget
====================

[](#yii2-ckeditor-widget)

CKEditor widget for yii2, support ckfinder,elfinder
This repo was forked from [2amigos/yii2-ckeditor-widget](https://github.com/2amigos/yii2-ckeditor-widget).
I made some customization.

Installation
------------

[](#installation)

```
composer require maxwen/yii2-ckeditor-widget

```

Configuration
-------------

[](#configuration)

Inorder to add your custom configure,
you need to add an controllerMap to you config/main.php:

```
'controllerMap' => [
	'ckeditor' => [
		'class'    => 'maxwen\ckeditor\controllers\EditorController',
		'viewPath' => '@vendor/maxwen/yii2-ckeditor-widget/views/editor'
	]
]

```

Then add you custom configure into params.php: see [CKEditor.config](http://docs.ckeditor.com/#!/api/CKEDITOR.config)

```
 // CKEditor config rewrite
'ckeditorConfig' => [
		// custom options
		'language'   => 'en',
		'font_names' => 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana',
		'toolbar'    => 'Full',
		'skin'       => 'your skin name here'
		// etc...
	],

```

Usage
-----

[](#usage)

The library comes with two widgets: `CKEditor` and `CKEditorInline`. One is for classic edition and the other for inline editing respectively.

Using a model with a basic preset:

```

use maxwen\ckeditor\CKEditor;

```

Using inline edition with basic preset:

```

use maxwen\ckeditor\CKEditorInline;

    This text can be edited now :)

```

How to add custom plugins
-------------------------

[](#how-to-add-custom-plugins)

This is the way to add custom plugins to the editor. Since version 2.0 we are working with the packagist version of the CKEditor library, therefore we are required to use its configuration API in order to add external plugins.

Lets add the popular [Code Editor Plugin](http://ckeditor.com/addon/pbckcode) for example. This plugin would allow us to add a button to our editor's toolbar so we can add code to the content we are editing.

Assuming you have downloaded the plugin and added to the root directory of your Yii2 site. I have it this way:

```
+ frontend
+ -- web
    + -- pbckcode
```

We can now add it to our CKEditor widget. For this example I am using `CKEditorInline` widget. One thing you notice on this example is that we do not use the preset attribute; this is highly important as we want to add a customized toolbar to our widget. No more talking, here is the code:

```
