Configuring CiviCRM to use the default Drupal editor¶
CiviCRM starting with versions 3.4.2/4.0.2 include a feature that allows administrators of sites running Drupal and the WYSIWYG API module to use Drupal input formats (text formats in Drupal 7), including their associated WYSIWYG profiles, as the rich-text editor in CiviCRM. The editor can then look and act the same when users edit rich text in CiviCRM as it does in native Drupal forms.
Required or useful modules¶
These modules are required or helpful when using the Default Editor option:
Installation and configuration¶
- Go to Administer > Customize Data & Screens > Display Preferences (screen and form configuration).
- For WYSIWYG Editor, choose "Drupal Default Editor".
- Optionally, change the default input format selected for forms with a rich-text control.
CiviCRM will then use Drupal's method of rendering and processing rich-text editor controls. WYSIWYG API must be installed for this to work; the option does not appear if it is not installed. Input formats configured to use a WYSIWYG profile will use that profile when selected. You can also enable or disable the rich-text editor and change input formats as you would in a native Drupal context.
Input formats are really output formats¶
Drupal and CiviCRM process and store text differently, even when CiviCRM uses the "Drupal Default Editor" option. Drupal does not generally process input before saving it to the database. It saves raw input and applies input formats—whose input filters modify text—when the text is output. Some advanced input filters depend on special tags in the raw input that are translated into HTML only on output.
CiviCRM does not know which input format was used for a field. It has no single point where it can process WYSIWYG-related fields just before output, nor a practical way to store the input format used for a field. As a result, the Drupal Default Editor for CiviCRM applies input formats before saving input to the database. The output is as expected, but you can't go back to the raw input.
If you edit a record with a WYSIWYG form after changing its input format, CiviCRM will not know which format you previously selected: the default editor will be selected. Advanced filters and WYSIWYG buttons that depend on manipulating template information in the raw HTML will not work because only the processed output is stored.
This is especially noticeable if you use an input format such as the default Filtered HTML without a WYSIWYG profile assigned to a field. In native Drupal, you edit it as plain text, optionally add HTML, and line breaks and links are converted to HTML when displayed. When you return to the field in CiviCRM after navigating away:
- The default input format chosen in the CiviCRM preferences screen will be selected, regardless of which input format you previously selected.
- Even if Filtered HTML is selected, the non-WYSIWYG text area will display HTML. The input format has already been applied to the raw code: newlines have been converted to paragraphs, links have been created, and so on.
IMCE as a file browser¶
If your WYSIWYG profiles are configured to use IMCE as a file browser, they will work when you edit rich-text fields in CiviCRM. You need IMCE and IMCE WYSIWYG bridge installed. See the README file in IMCE WYSIWYG bridge for installation instructions.
Tip
Using Drupal Default Editor along with an IMCE WYSIWYG profile is currently the only way to allow users to browse, upload and otherwise manage files on your server for use with mailings, event descriptions, etc.
Absolute paths¶
When using this option for CiviMail, take special care to ensure absolute URLs are output. The pathologic module is recommended for this task. Consider creating an input format specifically for CiviMail because it has special considerations. Apply pathologic as an input filter for that format; see the pathologic documentation for details.
One additional step ensures that Pathologic treats all resources as local and converts them to absolute URLs:
- Go to the input formats screen (admin/settings/filters/list).
- Click "configure" on the format, then click the "configure" tab.
- In the Pathologic filter settings, enter your site's base path in the "Also considered local" textbox. If your site is in the root, enter "/" (no quotes). If it is in a subdirectory, such as
http://www.example.com/drupal, enter "/drupal".