I’ve created a simple snippet version of FCKeditor. I had to because the web user side of the plugin didn’t seem to be as configurable as the manager user side, and it was getting too frustrating to try to make it work like it was supposed to.
I just downloaded the FCKeditor code, put it into a directory in the snippets folder, and gave it some parameters in the snippet. The code is rough and unrefined, but I’ll just paste the whole thing in here, just in case there’s anything useful to you as you work on your own code. Here’s what I have:
In the snippet:
<?php
/*
###################################
The FCKeditor snippet
http://wiki.fckeditor.net/Troubleshooting#head-791d6ceba9517cf0b1386179258a4e598c4eb4ff
Used to make the FCK rich text editor appear in the place of
a standard <textarea> in a form. Can be used multiple times
in the same form
PARAMETERS:
&base_path = the base path of the fckeditor snippet (default = /assets/snippets/fckeditor/)
&name = the name and id of the <textarea>
&value = the value to put in the field (can be blank)
&toolbar = the name of the toolbar to use (Default | Basic | Custom) The default is Custom (case sensitive)
&skin = which skin to use (default | office2003 | silver)
&width = width of textarea -- default = 100% (can be percentage or number of pixels)
&height = height of textarea -- default = 200px (don't include "px" in this value)
##################################
*/
include("C:/wamp/www/assets/snippets/fckeditor/fckeditor.php") ;
// CONFIGURATION:
if ($base_path=='') $base_path = '/assets/snippets/fckeditor/';
if ($name=='') $name = 'textarea1'; //Note: you MUST specify the field name if there is more than one textarea
if ($toolbar=='') $toolbar= 'Custom';
if ($skin=='') $skin = 'default';
if ($height=='') $height= '200';
if ($width=='') $width = '100%';
// END CONFIGURATION, BEGIN CODE
//&toolbar=Custom&name="+content+"&value="+value+"&skin=default&width=80%&height=600";
$oFCKeditor->BasePath = $base_path;
//original
$oFCKeditor = new FCKeditor($name) ;
//new one
//$oFCKeditor = new MyFCKeditor($name);
$oFCKeditor->Value = $value;
$oFCKeditor->ToolbarSet = $toolbar;
$oFCKeditor->Config['SkinPath'] = 'skins/'.$skin.'/';
$oFCKeditor->Width = $width;
$oFCKeditor->Height = $height;
$oFCKeditor->Create() ;
$editor = new MyFCKeditor($name);
$editor->Value = $value;
$editor->ToolbarSet = $toolbar;
$editor->Config['SkinPath'] = 'skins/'.$skin.'/';
$editor->Width = $width; //BUG: doesn't get the value from snippet call, for some reason
$editor->Height = $height; //BUG: doesn't get the value from snippet call, for some reason
$editor->returnEditor();
?>
To just make the editor show up, you can do this:
[!FCKeditor? &toolbar=`Custom` &name=`whatever` &value=`Here is the text.` &skin=`default` &width=`80%` &height=`600`!]
And here’s an example of how it was used in one instance within another snippet (taken out of context, of course, but you can probably see what’s going on:
$programedit .= "\t".$modx->runSnippet('FCKeditor',array('toolbar'=>'Custom','name'=>'sdescription','value'=>$_SESSION['sdescription'],'skin'=>'default','width'=>'85%','height'=>'300'))."</p>\n\n";
So there you have it, for what it’s worth. It works. If you can take it and refine it, great. If you can incorporate features like this into the plugin version so that it works equally well for the web user side of things, even better.