Sunday, May 3, 2009

Getting FCKEditor Styles Right in Drupal

We've got a multi-site install of Drupal and we like to place the more common modules at the global 'drupal_install/sites/all/modules' location. Being able to do this is great because it means that when a module needs to be upgraded it helps us upgrade all the sites that use that module at once.

Once such global module is fckeditor. While we do want the module to be stored once at the global level we also want to be able to customise the toolbar and styles for each site, and we want to keep those settings after a module upgrade.

So here's how it's done:

There are two important files used to style fckeditor in a drupal site.

1. fckeditor.config.js
This file belongs to the Drupal module (i.e. stored as ..../modules/fckeditor/fckeditor.config.js) and stores profiles of toolbar sets.

2. fckstyles.xml
This file belongs to FCKEditor itself (i.e. stored as ..../modules/fckeditor/fckeditor/fckstyles.xml)

To be able to customise FCKEditor for each drupal site in a multi-site install. Copy the two files above into your theme folder (i.e ..../themes/my_theme/).

Now, edit the fckeditor profiles you want to use (goto mydrupalsite.com/admin/settings/fckeditor and click 'edit' next to a profile).

Open the CSS fieldset and select 'Use theme fckstyles.xml' from the Predefined Styles options.






Open the Advanced fieldset and set Load fckeditor.config.js from theme path to 'yes'.









Now you can edit fckeditor.config.js and fckstyles.xml within your theme's path to customise fckeditor for only one site. When the time comes to upgrade fckeditor your styles and profiles will remain after the upgrade.

No comments:

Post a Comment