CFTEXTAREA or FCKEditor?
Posted: May 15th, 2009 | Author: Christopher Vigliotti | Filed under: ColdFusion, JavaScript | 4 Comments »If you want to add a rich text editor to your forms in ColdFusion 8 it’s as easy as CFTEXTAREA richtext=”true”…
<cftextarea richtext="true" name="formfieldname" toolbar="Basic" value="#form.formfieldname#" />
When this tag is called a bundled version of FCKEditor is called in to do the work. This simple solution works well in some situations, but not the one that I ran into the other day.
For example, if you want to customize FCKEditor to disallow users to text formatted in Microsoft Word you will have to edit the FCKEditor config files found in the belly of ColdFusion’s system files. Since I don’t have permissions to edit these files across all of the servers in the environments where my systems are run I’m left with one choice…ignore CFTEXTAREA richtext=”true” all-together and install a separate instance of FCKEditor.
Once you download and unzip FCKEditor you’ll find code samples for a host of languages. There are two examples for ColdFusion…a custom tag that works in versions 4.5.2 and beyond, as well as a ColdFusion Component. I chose to the custom tag as I generally try to shy away from encapsulating display logic in CFCs. I was able to configure and call FCKEditor from my page with a few lines of code.
1 2 3 4 5 6 7 8 9 10 | <cfscript> thisTag.editorArgs.instanceName = "formfieldname"; thisTag.editorArgs.basePath = "/inc/misc/editor/"; thisTag.editorArgs.value = form.formfieldname; thisTag.editorArgs.toolbarSet = "Basic"; thisTag.editorArgs.config = StructNew(); thisTag.editorArgs.config.ForcePasteAsPlainText = true; </cfscript> <cfmodule template="/sso/assets/editor/fckeditor.cfm" attributeCollection="#thisTag.editorArgs#" /> |
Yup, it’s that easy. Pretty cool, eh?
has anyone found a workaround to allowing JS in fckeditor?
it works in fckeditor but when i submit from a cflayout it doesn’t recognize the new changes. with cftextarea it craps out if you have a script tag in there…
why not:)
Is there a CF 8 Text Editor out there that can allow pasting content in a text area, but override any code , so I maintain consistent font styles and size in the text area they are pasting into?? Help.
Theres gotta be a solution besides FCK !
Thanks.
Hmm…if your requirement is to apply a specific style I’d try either hacking FCK or just having users paste text into an old-fashion textarea.