We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    Hi there,

    Im writting a module to edit site content.
    Is there an easy was to include the RTE that modx uses for the normal page editing?

    I want all the same features etc, but just in my module?

    Thanks

    J
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      ConseilsWeb updated my mailing list port to use the RTE:
      // Get access to template variable function (to output the RTE)
      include_once($modx->config['base_path'].'manager/includes/tmplvars.inc.php');
      	  
      $event_output = $modx->invokeEvent("OnRichTextEditorInit", array('editor'=>$modx->config['which_editor'], 'elements'=>array('tvmailMessage')));
      	
      if(is_array($event_output)) {
      	$editor_html = implode("",$event_output);
      }
      // Get HTML for the textarea, last parameters are default_value, elements, value
      $rte_html = renderFormElement('richtext', 'mailMessage', '', '', '');
      		
      echo $rte_html;
      		
      echo $editor_html;
      

      You should be able to use it as-is, other than changing the ’mailMessage’ parameter to whatever the name of your textarea field.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org