Drupal 7 WYSIWYG - as a FEATURE
Every Drupal developer knows that there many configuration settings that are similar between the sites that they build, whether it's a personal preference or a trend among clients. And every developer that has been around Drupal more than a few minutes knows about the Features module.
Well on Tuesday, I was at the stage of configuring the WYSIWYG for a new client's hopefully-soon-to-launch website. And I honestly dreaded the step of configuring the WYSIWYG. Yes, I could do it pretty consistently in my sleep by now, but doing the same thing over and over feels so tedious. And it really sucks when you go through that routine, think you did everything right, and then get a call about an issue months later that has to do with that one overlooked checkbox or missed keystroke.
So I thought I'd search for that WYSIWYG issue where they were working on Features support. It had not really gotten anywhere the last time I had looked at it, so I had decided just to wait until it made it into a release. And guess what? There was a working patch that had been committed to -dev just days earlier!
A lot of people said the patch worked just fine against the current stable release (2.1), so I decided to just go ahead and apply the patch. I think I can count on my fingers (and maybe toes) how many times I've been more excited to see something just plain work!
So if you go ahead and apply that patch, you can now export most (or all, depending on what other modules you use and their support) of your WYSIWYG configuration as a Feature. And that means that those dozens of checkboxes and textareas can automatically be configured with one click.
For those who haven't worked with Features, here's a quick lesson:
- Install and configure your modules as desired.
- Make sure the Features module is installed.
- Go to admin/structure/features
- Click Create Feature
- Fill out the form as necessary.
- Click Download Feature. You'll download a module that now goes in the sites/*/modules folder and contains the dependencies list and all of the configuration that was exportable.
- To enable your new Feature, go to admin/structure/features. It should be in the list. Check the box and wait.
- Make sure no one is looking and do your happy dance.
One nice thing about the Features module is that it automatically detects the dependencies required for your feature. That means that, in the case of exporting a fully configured WYSIWYG, you'll just have to select "WYSIWYG profiles: wysiwyg" under "Edit Components" and then check the boxes for the profiles that you want to export. It will detect what modules are necessary for that configuration, and them to the .info file as a dependency, and (if the module has exportables) put the configuration into code.
If you want to see what my WYSIWYG feature is like, feel free to get it from GitHub. Note: You will need to get the CKEditor library separately and install it to sites/*/libraries.