ashanet/ckeditor

There is no license information available for the latest version (1.5) of this package.

CkEditor plugin for CakePHP 3.x & 4.x

Maintainers

Details

github.com/ashanet/CkEditor

Source

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 5

Type:cakephp-plugin

1.5 2020-08-27 20:02 UTC

This package is auto-updated.

Last update: 2024-04-29 04:53:21 UTC


README

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require ashanet/ckeditor

Then in config/bootstrap.php add:

$this->addPlugin('CkEditor');

In either src/Controller/AppController.php, or any controller where you want to use CKEditor, add:

$this->viewBuilder()->setHelpers(['CkEditor.Ck']);

Finally, in your template file, simply add this to call CKEditor:

echo $this->Ck->control('field_name');

This is the equilivant of using

echo $this->Form->control('field_name');

Except that CKEditor will be loaded instead of a text area!

Advanced Options

You can make adjustments to CKEditor and the form input as needed. There is full flexibility in this regard.

The full explaination is as follows:

echo $this->Form->control($input, $options, $ckEditorOptions, $ckEditorUrl, $ckEditorPlugins);
@param string $input

The name of the field, can be field_name or model.field_name

@param array $options

Options include $options['label'] for a custom label and any other custom Form Helper options

@param array $ckEditorOptions

This will pass any options from http://docs.ckeditor.com/#!/guide/dev_configuration to CKEditor

@param string $ckEditorUrl

This gives an option to overwrite the CKEditor URL. You can use a local URL then if required.

@param array $ckEditorPlugins

An array of locally installed CKEditor plugins to include, as one sub-array per plugin, in the format specified in the CKEditor documentation at https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_plugins.html#addExternal.

Examples

Use an associated field name

echo $this->Ck->control('category.description');

Generate a custom label

echo $this->Ck->control('field_name', ['label' => 'A unique label']);

Add options to CKEditor from http://docs.ckeditor.com/#!/guide/dev_configuration

echo $this->Ck->control('field_name', [], ['fullPage' => true, 'allowedContent' => 'true']);

Load a local version of CKEditor, or a different version

echo $this->Ck->control('field_name', [], [], '/js/ckeditor.js');

Load a locally installed CKEditor plugin

echo $this->Ck->control('field_name', [], [], null, [['myplugin', '/ckplugins/myplugin/', 'myplugin.js']]);

Example showing all the options together

echo $this->Ck->control('field_name', ['label' => 'A unique label'], ['fullPage' => true, 'allowedContent' => 'true'], '/js/ckeditor.js', [['myplugin', '/ckplugins/myplugin/', 'myplugin.js']]);