Adding TinyMCE to blogCFC admin area
It's quite easy to get the admin entries editor to use tinyMCE. All you have to do is edit the textArea.cfm file which is found in /blog/tags/.
Updating the editor page
Add this code to the textArea.cfm page (just beneith the output tag)<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="#application.rooturl#/includes/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom"
});
</script>
<!-- /tinyMCE -->
</cfsavecontent>
<cfhtmlhead text="#request.tinyMCE#" />
As the tinyMCS javascript needs to be in the header of the page we save the JS content to a variable called request.tinyMCE using cfsavecontent - we then post this to the header of the page using coldfusions cfhtmlhead tag.
Setting up tinyMCE - As easy as 1,2,3
1. Create a folder called 'tinymce' in the /includes/ folder (/blog/includes/)2. Copy the jscripts folder (from your tinyMCE download) into the includes folder so you should have this structure /blog/includes/tinymce/jscripts/
3. Test - go into your admin area, click add entry watch it load.
You can call this textArea.cfm from the page.cfm and textblock.cfm
Remember to brake out of the cfoutput when calling this module.
What is TinyMCE
TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB.





ta.
Adding fckeditor is as easy or more, because there's no need for anything to be in the header. just add (hopefully I can insert scripts here):
<cfscript>
fckEditor = createObject("component", "fckeditor.fckeditor");
fckEditor.instanceName="body";
fckEditor.toolbarSet="blog";
fckEditor.basePath="#GetDirectoryFromPath(script_name)#fckeditor/";
fckEditor.value=form.body;
fckEditor.width="500";
fckEditor.height="300";
// ... additional parameters ...
fckEditor.create(); // create instance now.\
</cfscript>
That's all.
<blockquote>
TimyMCE is very easy to integrate into any code. It just replaces <TEXTAREA> tag with the WYSIWYG-editor with a few lines of code. So thers no need to rewrite the code at all.
</blockquote>
Okay so you have to add the tag to put it into the header - but if you use the WYSIWYG sitewide then this would save you some time. The example I have loads a lot of the extra features - you don't need then all which would make your code smaller.
Critter - I'm glad to help.
How did you handle the "<code>" within tinyMCE?
Thanks for posting this.
I have tried IE7 and FF2, on XP and Vista.
into the BODY field. Too bad the TinyMCE image function can't upload.
Unless TinyMCE has image features I'm not aware of?
Blogcfc Rocks!
Now, I have a problem with a SWF file. I embed it but when I save, the "object" code is not there. Not sure if this is tinymce or blogCFC doing.
I know it's not blogCFC as i have used flash on several blog posts. Check out this post, maybe you need the admin component for tinyMCE: http://forum.mamboserver.com/showthread.php?t=3711...
I am using the FCKeditor.
I am having a problem. I have FCKeditor running. However, when I post an entry, I am seeing the html converted out to extended characters. Thus "Testing" shows up as "<p>Testing</p>".
When I view source in FCKeditor, I see "<p> lt;p gt; Testing lt;/p gt; </p>". & character removed to keep from being viewed as html.
Any ideas on fixing this or what I might be doing wrong?
I am going to cross post this to see if others might have an idea also. Please forgive me if that is offensive to you...
Regards,
Josen
In fckeditor.cfc line 167 needs changing from:
input type="hidden" id="#this.instanceName#" name="#this.instanceName#" value="#HTMLEditFormat(this.value)#" style="display:none" /
to:
input type="hidden" id="#this.instanceName#" name="#this.instanceName#" value="#this.value#" style="display:none" /
apply_source_formatting: true,
remove_linebreaks: false,
more info here: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/apply_source_formatting
http://jamesallen.name/index.cfm/2007/11/19/Fixing...
<code>
<cfsetting enablecfoutputonly=true>
<cfprocessingdirective pageencoding="utf-8">
<!---
Name : textarea.cfm
Author : Raymond Camden
Created : July 11, 2006
Last Updated : September 15, 2006
History : Use id (rkc 9/15/2006)
Purpose : Makes it easier to add a Rich Text Editor, for you wimpy folks who can't write html by hand.
: I tell ya - in my day, we wrote our HTML by hand and we liked it gosh darnit. We didn't even
: have monitors. We had to write our HTML with punchcards. And our punchcards were made of tissue
: paper and would break if you didn't write it exactly right.
--->
<!---
The following attributes are always passed in. You may not need them for your RTE,
but they are here for your use.
--->
<!--- Name of the form field. --->
<cfparam name="attributes.fieldname">
<!--- The value to use --->
<cfparam name="attributes.value" default="">
<!--- CSS class of the text area --->
<cfparam name="attributes.class" default="">
<!---
NOTE: This is where you replace my code with your code. You may want to juse comment out my code
in case you have to roll back.
--->
<cfoutput>
<!---<textarea name="#attributes.fieldname#" id="#attributes.fieldname#" <cfif len(attributes.class)>class="#attributes.class#"</cfif>>#attributes.value#</textarea>--->
<cfsavecontent variable="request.tinyMCE">
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="#application.rooturl#/includes/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom"
});
</script>
<!-- /tinyMCE -->
</cfsavecontent>
<cfhtmlhead text="#request.tinyMCE#" />
<cfsetting enablecfoutputonly=false>
</cfoutput>
</code>
Can you tell me what the problem is?
*** the editor does not show up ***
Solved
The html generated contains two
<code>
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="http://john.stottlemire.com/includes/tinymce/jscri..."></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen",
width : "100%",
height : "500",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom"
});
</script>
<!-- /tinyMCE -->
</code>
and also contains two
<code>
<textarea name="body" id="body" class="txtArea"></textarea>
</code>
I've examined the page.cfm and textarea.cfm pages and cannot figure out why this happens.
The code works fine for adding new entries to the blog.
Any ideas why this may be happening?
-john
"I Like Those Fixes ... "
Sorry, I had left out a comma in the JS code ... that was all ...
However, I solved that problem only for but a short period later, have another develop ... The <code> tag issue ...
I have gone through the moxie wiki, and there are numerous references regarding the addition of the <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/extended_valid_elements">"extended_advanced_elements" </a> options in the tinyMCE init() function as such ...
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen",
width : "100%",
height : "500",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
<strong>extended_valid_elements </strong>: "code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
+"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
+"|title]",
});
Yet, that still did not provide the solution ...
Another matter apart from the <code> tag matter, is of a default text size ...
In the documentation, there is a reference to <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/theme_advanced_font_sizes">Advanced font sizes </a> but all the solutions I have tried have not worked ...
The documentation is not too easy to navigate either ...the examples are not all that helpful.
Moreover, the forum support is not what you might call, inviting.
Again, sorry for not posting the resolution, in essence ~ I haven't found that the editor is practical enough to merit using, and I may try to use FCK Editor ... If that fails, hell with it ... I 'll hand code my posts, or simply use Live Writer ...
http://extjs.com/forum/member.php?u=46541
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46542
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46543
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46545
http://extjs.com/forum/member.php?u=46548
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46558
http://www.mountwashington.org/forums/member.php?u...
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46567
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46571
http://extjs.com/forum/member.php?u=46573
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46574
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46578
http://www.mountwashington.org/forums/member.php?u...
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46579
http://extjs.com/forum/member.php?u=46581
http://www.mountwashington.org/forums/member.php?u...
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46582
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46583
http://www.mountwashington.org/forums/member.php?u...
http://extjs.com/forum/member.php?u=46584
http://extjs.com/forum/member.php?u=46585
http://www.mountwashington.org/forums/member.php?u...
http://www.mountwashington.org/forums/member.php?u...
http://www.mountwashington.org/forums/member.php?u...