In a CMP, how does one load the system rich text editor? I’ve seen some mention of a MODx.loadRTE()
but I can’t find that in any docs and I get an error in the console saying it’s not a function.
You have to register the RTE before you can invoke MODx.loadRTE()
. Glossary uses an RTE in the CMP:
I have something similar in my controller file. I’m extending modParsedManagerController
though; does that make a difference?
class FBECEventsDetailManagerController extends modParsedManagerController {
public function loadRichTextEditor(){
$useEditor = $this->modx->getOption('use_editor');
$whichEditor = $this->modx->getOption('which_editor');
if ($useEditor && !empty($whichEditor))
{
// invoke the OnRichTextEditorInit event
$onRichTextEditorInit = $this->modx->invokeEvent('OnRichTextEditorInit',array(
'editor' => $whichEditor, // Not necessary for Redactor
'elements' => array('foo'), // Not necessary for Redactor
));
if (is_array($onRichTextEditorInit))
{
$onRichTextEditorInit = implode('', $onRichTextEditorInit);
}
$this->setPlaceholder('onRichTextEditorInit', $onRichTextEditorInit);
}
}
public function process(array $scriptProperties = array()) {
$this->loadRichTextEditor();
return '[[fbec-detail]]';
}
public function getPageTitle() {
return 'Event Detail';
}
}
I never used the modParsedManagerController class. Sorry.
Please take a look if MODx.loadRTE() is defined in the custom manager page HTML output. Otherwise the onRichTextEditorInit placeholder has to be added somewhere, since you set it in your code.
It is also possible that it is caused by the order of execution in the custom manager page. Maybe MODx.loadRTE() is defined too late.