I was recently given the task to import an unmodified XML dataset into a web-based tool as tabular data, HTML'ified, and allow for visual editing of the information, and they wanted to use Wordpress. I thought, "Okay, that should be easy enough." Well, okay, do I create a plugin to handle the import? I don't really want to learn Wordpress hooks and programming functionality considering I hate the thing...no, I'll just import it directly into the database. I used a diff tool to discover that creating a new draft entry only modifies three database tables anyway, that's easy enough. Got that working, 1-2-3, lickity-split!
But now, we need to let staff have access to modify the tabular data.
Wordpress uses TinyMCE internally as its Visual Editor (a Rich Text Editor, as more people will be accustomed to it being called). I've worked with TinyMCE before, so figuring out how to get the advanced view to work will be a piece of cake...
...or so I thought, yet again...
Apparently, Wordpress has literally integrated TinyMCE into its system, which can be a good thing, I suppose, if they actually finished making it dynamically controlled (as I have heard the Drupal team has done). If you want to change the Visual Editor, you need to manually modify Wordpress code, create a plugin that uses the hooks (if you knew what they were) to modify Wordpress' default behavior, or create a plugin that is a complete replacement of the internal Visual Editor. YAY!
In my search to find possible solutions that wouldn't force me to create redundant code, I found the most suitable solution to be Labnotes' "Advanced WYSIWYG" plugin. Although I had to modify the actual plugin code to make it behave how I wanted/needed it to, the only thing I had to modify was a simple array variable list. In essence, it actually seemed easier to modify than that default TinyMCE way of modifying itself.
The Labnotes code was small and friendly, but I did have to modify three functions to get it to work the way I needed it to. For some reason, my modifications changes the appearance of the TinyMCE window (adds padding or margin to the JS iframe), but it's such a small oddity that I didn't feel like researching it further. My modifications can be found below:
With the above changes, I set the extended tools on hidden layers (as Wordpress does, but accidentally hides the extend button), and attempted to mimic (only slightly off-from default) the default layout of Wordpress' default layout for their Visual Editor button arrangements. I also added in table controls (YES! I can now modify rows, columns, cells, etc...all from within the RTE) and full screen entry editing to boot, because with tabular data, the visual editor window will be pretty darn cramped.
TinyMCE supports many other possible plugins, and they too can be implemented using this plugin, although similarly you'd have to modify the functions you see above to fit your needs, but all it's doing is telling TinyMCE which buttons to load, which in turns have certain plugin requirements. Wordpress doesn't include all the plugins by default, and if you wanted to extend it to use a certain feature that is not contained in Wordpress' package (such as table controls, or fullscreen view), you'd have to determine which version of TinyMCE is packaged with your version of Wordpress (just open up any of the TinyMCE files under the "js" directory in your wp-content/plugins" folder, it should have a version number somewhere), go to SourceForge where TinyMCE holds its repositories for public download, and grab the same version's package, export the plugins folder, and upload your necessary plugins to the appropriate plugin folder for Wordpress' TinyMCE. ...It sounds like a lot, but it really isn't.
So, now that I can finish this project up for the time being (after Wordpress training for the staff that have already been trained, of course -- they're nervous of technology), I can kick Wordpress in the nuts and move on to something better. Hopefully my own experiences can help someone else out a little. BTW, I </3 Wordpress (It's NOT a CMS, people!).
Oh yes, did I mention how Wordpress "helps" you clean your code by removing any properties it hasn't programmatically understood, such as a table's summary, the caption tag, and other types of things? ...and here I thought I'd try to be nice and semantic. Darn Wordpress!


0 Trackbacks