WYSIWYGPro Helper and tutorial

By Barry (brightball)
I couldn't find any resources on setting up WYSIWYGPro with Cake so I developed this helper along with instructions for total integration with your system. If you've never used WYSIWYGPro, you should check out the demos. I've tried every WYSIWYG editor out there and none of the other ones even come close as far as I'm concerned.
WYSIWYGPro is actually PHP based. It assumes a PHP backend and has a lot of callbacks, tie ins, configuration, and extension options. From a purely interface standpoint it's tremendously more stable than any other that I've used (especially when switching from source editing and back) and provides valid XHTML. Images and can be inserted and displayed in-line making it feel much more like a desktop editor. There's even a full screen mode.

I mentioned integration. For images, documents, and media files WYSIWYGPro will allow you to give users file browsing access wherever you allow, thumbnail image selection, uploading right there in the interface, as well as alignment, padding, rotation, resizing and title editing (with preview). Even video thumbnails with ffmpeg and customizable embedded flash players.

There's also a hyperlink interface that makes creating direct links and mail to links easy. One of the extensions offers the ability to load a tree list of URLs from your site so that your end users can just pick the page that they want to link to rather than copying and pasting URLs. The logic for creating this tree is up to you but I'll show you how I did it for an example.

For those clients that refuse to stop copying and pasting from MS Word (you know who I'm talking about) there's even a C&P from Word feature that will selectively strip out all of that formatting for you. Every feature can be easily turned on and off as well.

The downside to WYSIWYGPro of course, it's not free. It is pretty reasonable though, however, those types of decisions are up to you.

Check it out at:
WYSIWYGPro
Once you have everything setup as detailed below, all that you have to do to use WYSIWYGPro in your code will be:

View Template:

Download code
<?php echo $wysiwygpro->input('Content.stuff'?>

On to setup. Once you've downloaded WYSIWYGPro, drop the entire folder into app/webroot/wysiwygPro. I realize that the vendors folder is where this kind've thing should usually go, however, there's a lot of files and images that WYSIWYGPro automatically links to and it's tremendously simpler this way.

Next, there are a couple of configuration files to edit. Open up wysiwygPro/config.inc.php and find line 90 which should be:

Download code
define('WPRO_SESSION_ENGINE', '<SESSION_TYPE>');

should be either PHP or WP. WP allows WYSIWYGPro to handle their session information independently. PHP will uses the default PHP sessions. If you'd like to include your own session logic, you may wish to take a look at the wysiwygPro/conf/customSessHandlers.inc.php file to add your own custom session handler. I wrote one for this exact purpose which you can find here:

Using Cake Sessions Outside of Cake
This seems to have issues when using Cake's database sessions but only on IIS. Works fine otherwise and I'm not sure what the issue is with IIS. Haven't had any problems with a LAMP configuration though.

For easiest use though, I recommend setting to WP. It will work independently of your stuff, you don't have to worry about session names, etc. Much simpler. You'll also want to make sure that the wysiwygPro/temp directory is writable.

The one giant warning from WYSIWYGPro is not to allow access to any of the uploader or browser functions by default. This is how it is already setup. Those should be set when you create the editor and they are stored in session. That way you can create settings specially for your logged in users, giving them access to their own personal directory, etc.

Page 2: config/wysiwygpro.php

Comments 936

CakePHP Team Comments Author Comments
 

Comment

1 yeah

Nice work, thanks for taking the time to share!
Posted Jul 2, 2009 by Matthew
 

Comment

2 Yeah, not sure what happened with Drupal either

I've heard about that on several occasions. One thing that swung me from Drupal to Joomla way back when I was still using them was the availability of WYSIWYGPro plugins just because of how much easier it makes things for clients.
Posted Jul 4, 2009 by Barry
 

Comment

3 WPro

Thanks for a great article. I've tried it and it works perfectly.

WPro seem to be my solutions when I take a look on it. However, after spent my plenty money (64USD is not a 'small' amount in my country, it can feed some family for weeks) for the developer version, what I really get is an incomplete documentation and some emotional reply message to my service request. So, I decide to ask for the refund.

Anyway, your article still give me some idea for my current project.

Thanks!
Posted Jul 12, 2009 by Chawalit Limsowan
 

Comment

4 WYSIWYGPro Helper and tutorial

Really works. Thank you.
Posted Feb 19, 2010 by revizyon