7

The question

Where/how can I override the default CKEditor configuration files in CiviCRM?

Original issue / follow-up question

We have a custom email template that uses <html>, <head>, <body>. When using CKEditor, if you paste the template in 'Source' and then flip back out of the source view the tags mentioned above are stripped out. This is because the CKEditor default setting is to strip these tags.

I've opened a follow-up question here: How can I use <html>, <head>, <body> tags in a mailing?

6
  • Note: the fullPage config option is not the solution - this adds the <html><head><body> tags everywhere rather than just not stripping them out.
    – John
    Commented Aug 7, 2015 at 13:04
  • I've modified config.js before and it's been reflected in Civi, so that should work. Commented Aug 7, 2015 at 13:19
  • Hi, unfortunately config.js doesn't seem to get included, and there are two other places that CKEditor gets config defined: in ang\CRMUi.js and also in QuickForm package for textareas. So there's at least two different approaches going on :P
    – John
    Commented Aug 7, 2015 at 13:23
  • @AndrewWest Perhaps the config.js only affects CKEditor instances in the QuickForm approach, but not the Mailing interface which is loaded via angular...
    – John
    Commented Aug 7, 2015 at 13:51
  • ah, that's possible - the changes I needed were when generating PDFs, so I didn't hit the mailing interface. Sorry to mislead! Commented Aug 7, 2015 at 14:39

2 Answers 2

13

To answer your question about how to modify CKEditor's config.js:

In 4.6

You need to "hack" the config.js file within CiviCRM itself (packages/ckeditor/config.js). Editing this file will modify all instances of CKEditor in CiviCRM (angular and quickform add a few additional settings related to file uploads but they do both respect that file). If you don't see your changes right away, clear your browser's cache. Note that this file will be overwritten with every upgrade.

In 4.7

4.7 adds a GUI in Display Preferences to modify plugins and button groups, and this will generate at least one config file named crm-ckeditor-default.js in your files/civicrm/persist directory (more files will be created if you click other tabs e.g. for CiviMail or CiviEvent). This file won't be overwritten during upgrades, but will be overwritten if you make changes from the GUI. There is also a new hook_civicrm_coreResourceList which you can use to specify a different config file depending on whatever logic you want like current page, current user, etc.

5
  • Thanks coleman, this answers the original question (which spawned a million others, sorry).
    – John
    Commented Aug 7, 2015 at 14:53
  • I've split out the other question to try and keep this one tidy.
    – John
    Commented Aug 7, 2015 at 15:07
  • For 4.6 - would there be a way to override the config.js file via an extension, or is it too hard-coded?
    – Alan Dixon
    Commented Mar 27, 2016 at 2:55
  • There might be a way to hack around it, like have the extension push some js onto the page that overrides ckeditor settings. It might be a pita though.
    – Coleman
    Commented Mar 27, 2016 at 16:11
  • If it helps, I wrote some stuff for adding fonts, and just found this thread. It basically is an example for 4.7 to what you are proposing here. Can be found here: civicrm.stackexchange.com/questions/22260/…
    – Phil_B
    Commented Mar 1, 2018 at 13:20
0

We had the same problem on a multisite / Aegir system and after much work solved this.

Our solution is detailed here: Solved: Is this a bug - [civicrm.files] variable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.