One more change that needs to be made. Ryan and I have been doing a little e-mail tagging regarding the recent work on the default content. One of the things I noticed was a small problem dealing with the use of RTE’s on the frontend. The problem seemed to be that unless a width and height is expressed for the editor itself, there’s a possibility that it won’t stay within the boundaries of its div element. So...I felt it best to simply modify the RichText widget type so that the width and height is passed to the OnRichTextEditorInit event. After that, it’s just a simple matter of modifying the plugin code to assign a width and height if present (in this case, in the FCKEditor code). The change is as follows:
In /manager/includes/tmplvars.format.inc.php
Around line 136:
case "richtext":
$value = parseInput($value);
$w = $params['w']? $params['w']:'100%';
$h = $params['h']? $params['h']:'400px';
$richtexteditor = $params['edt']? $params['edt']: "";
$modx->regClientStartupScript("manager/media/script/bin/webelm.js");
$o = '<div style="position:relative; width:'.$w.'; height:'.$h.';"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">';
$o.= htmlspecialchars($value);
$o.= '</textarea></div>';
$replace_richtext = array($id);
// setup editors
if (!empty($replace_richtext) && !empty($richtexteditor)) {
// invoke OnRichTextEditorInit event
$evtOut = $modx->invokeEvent("OnRichTextEditorInit",
array(
editor => $richtexteditor,
elements => $replace_richtext,
forfrontend => 1
));
if(is_array($evtOut)) $o.= implode("",$evtOut);
}
break;
Change to:
case "richtext":
$value = parseInput($value);
$w = $params['w']? $params['w']:'100%';
$h = $params['h']? $params['h']:'400px';
$richtexteditor = $params['edt']? $params['edt']: "";
$modx->regClientStartupScript("manager/media/script/bin/webelm.js");
$o = '<div style="position:relative; width:'.$w.'; height:'.$h.';"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">';
$o.= htmlspecialchars($value);
$o.= '</textarea></div>';
$replace_richtext = array($id);
// setup editors
if (!empty($replace_richtext) && !empty($richtexteditor)) {
// invoke OnRichTextEditorInit event
$evtOut = $modx->invokeEvent("OnRichTextEditorInit",
array(
editor => $richtexteditor,
elements => $replace_richtext,
forfrontend => 1,
width => $w,
height => $h
));
if(is_array($evtOut)) $o.= implode("",$evtOut);
}
break;
You can see that it’s a relatively small change...just a few additional parameters passed into the array for the OnRichTextEditorInit call. A couple of things to remember about this though...the parameters can, of course, be ignored in the plugin but you have to test the plugin to ensure that it works correctly when used as a frontend TV. Also, the width and height can be expressed with pixels (i.e. 400px). FCKEditor doesn’t like having a ’px’ on the end so it’s necessary to make sure and strip it out if it’s present in the variable. I’ve also attached the updated code for FCKEditor that has a TPL file reflecting these changes. As always, make sure that the TPL file is updated.
Another thing that was discussed was the assignment of a custom ’web user’ theme/toolbar for every RTE. FCKEditor already has this feature as part of its configuration tab. Once TP3.3 is released, I’ll make sure and update Xinha and TinyMCE to allow a similar feature.
That’s all for now!
Jeff