Hi Hussein,
I am still really struggling with this and for some reason none of this works for my application, or it gives me some odd behavior, i.e. I need to have both an instance of 'redactor' and 'redactor2' in the template. I've had different elements working, but nothing consistently, so I have built a quick test page to see if I can get to the bottom of what is happening.
To start from the beginning, so I leave zero stones un-turned, I am using Perch v3.1.6.
I have added define('PERCH_CUSTOM_EDITOR_CONFIGS', true); into my config file.
Now the more I have looked at things, the more confused I am. Perch v3 ships with two versions of redactor in the plugins folder, namely redactor and redactor 2.
There seems to be some chatter that the 'default' version of redactor that is now shipped with Perch v3 is redactor v3 or is this just nonsense ?
In my template, I am currently calling a test textarea with: <perch:content id="testredactor" type="textarea" label="Redactor" html editor="redactor">
Now, the first thing I want to get into my head is that, as I want to expand/reduce the functionality of different configs of redactor, is it best to use editor="redactor" or editor="redactor2".
For example, in previous trials, I have managed to get the plugin 'counter' working for redactor, but it does not display if I change the editor to redactor2.
Anyway, skipping ahead. After reading your blog (link you provided above), I have tried to get the following config.js file working. Again, for completeness, this file is sitting at the location /addons/plugins/editors/config.js
and I have downloaded and added redactor plugins from: https://imperavi.com/redactor/plugins/ which are located at: /addons/plugins/editors/redactor-plugins/
Using your code in the blog for the plugin fontcolor, I have a config.js file of:
- Perch.UserConfig.redactor = function(){
-
- var get = function (profile, config, field) {
-
-
- // check whether the plugin 'fontcolor' is already in the array plugins
- if (config.plugins.indexOf('fontcolor') === -1) {
- // if not, add it
- config.plugins.push('fontcolor');
- }
-
- return config;
- };
-
- var load = function (cb) {
- jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/fontcolor.js', cb);
- };
- return {
- 'get': get,
- 'load': load
- }
-
- }();
Display More
All fine so far.
But, if I want to add another plugin, such as 'counter', I download the appropriate js file from imperavi and then I would write something like:
- Perch.UserConfig.redactor = function(){
-
- var get = function (profile, config, field) {
-
-
- // check whether the plugin 'fontcolor' is already in the array plugins
- if (config.plugins.indexOf('fontcolor') === -1) {
- // if not, add it
- config.plugins.push('fontcolor');
- }
- // check whether the plugin 'counter' is already in the array plugins
- if (config.plugins.indexOf('counter') === -1) {
- // if not, add it
- config.plugins.push('counter');
- }
-
- return config;
- };
-
- var load = function (cb) {
- jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/fontcolor.js', cb),
- jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/counter.js', cb);
- };
- return {
- 'get': get,
- 'load': load
- }
-
- }();
Display More
Which is not working because I am pretty sure I have called the load function incorrectly.
The thing is, if I look at the documentation and other posts wrt config files, they all seem to write things differently and I cannot get an understanding, or consistency on what is happening.
Also, do some plugins not work with redactor or redactor2 ? As you an see, I am completely confused ! and any help would be greatly appreciated.
I've spent hours going through different posts, different types of config and still cannot get any clarity on which redactor to use, to enable the plugins to work and how best to wrote the config file.
Thanks,
Andy