Jump to content

CKEditor settings per template and/or role


gebeer
 Share

Recommended Posts

It would be fantastic if we could set different configurations for CKEditor fields based on template or user roles.

Like described on https://weekly.pw/issue/14/ under "More CKEditor upgrades", we can use config files in /site/modules/InputfieldCKEditor/ to store settings per field. E.g. for the body field this would be

/site/modules/InputfieldCKEditor/config-body.js.

Maybe this logic could be extended to something like

/site/modules/InputfieldCKEditor/config--field-body--template-home--role-mycustomrole.js.

I was coming over from Joomla to PW couple of years ago and there we had an excellent CKEditor integration called JCE where you could define settings per user role etc.

Maybe I am wrong but up to now we need to create additional fields if we need editor config settings per template. If there already is a way to do that I'd be happy to know. 

  • Like 7
Link to comment
Share on other sites

  • 4 years later...
  • 2 months later...
On 10/19/2020 at 10:26 AM, modifiedcontent said:

Is CKeditor now part of Processwire? I use CKeditor in a template, but using a version I downloaded in a template js folder. What is the correct way to use CKeditor in a template, on the front-end?

 

You can load all the CKEditor assets in a template by loading the module

$modules->get('InputfieldCKEditor');

This will load all assets to $config->scripts and $config->styles
Now in your main.php (or template file that renders your <head>) you need to include something like

foreach ($config->styles as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />\n";
foreach ($config->scripts as $file) echo "\n\t<script src='$file'></script>\n";

This approach is only working with the delayed output strategy.

  • Like 1
Link to comment
Share on other sites

On 11/1/2020 at 7:54 PM, modifiedcontent said:

Did you find solutions for your original question from 2016, CKEditor settings per template and/or role? I'll have to figure that out next and will post here what I find out.

Here is one possible way to go about this:

  1. add the user role and template name to the ProcessWire.config JS object with https://processwire.com/api/ref/config/js/
  2. in /site/modules/InputfieldCKEditor/config.js retrieve that information and setup different CKEditor configs depending on role/template

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...