We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8740
    • 36 Posts
    I’m creating a module and would like the to use the default RTE in it.
    Here’s some code I have, but it only make a textarea box and doesn’t use the RTE..

        <div class="MODX_RichTextWidget">
         <textarea id="postContent" name="postContent" style="width: 100%; height: 400px"></textarea>
        </div>
    <?php
         // New post
         // Get access to template variable function (to output the RTE)
         include_once($modx->config['base_path'].'manager/includes/tmplvars.inc.php');
    
         // invoke OnRichTextEditorInit event
         $replace_richtexteditor = array('postContent',);
    
         if(is_array($replace_richtexteditor))
          {
           $evtOut = $modx->invokeEvent('OnRichTextEditorInit',
                                        array('editor'   => $modx->config['which_editor'],
                                              'elements' => $replace_richtexteditor));
           print_r($evtOut);
    
           if(is_array($evtOut))
            {
             echo implode("", $evtOut);
            }
          }
    ?>


    It download the RTE’s javascript, but just doen’t convert the area to an rte..
      • 8740
      • 36 Posts
      I get two javascript errors:
      Error: u is undefined
      Source File: http://localhost/modx/manager/index.php?a=112&id=4
      Line: 0

      Error: tinyMCE is undefined
      Source File: http://localhost/modx/manager/index.php?a=112&id=4
      Line: 1

        • 8740
        • 36 Posts
        Actaully this is a TinyMCE issue. If calling a page with the TinyMCE stuff on it via Ajax, it’s going to have problems, talk about a fix is here http://www.crossedconnections.org/w/?p=88
        Also something about gziping the output can have issues?

        I’m going to try a couple more things.
          • 8740
          • 36 Posts
          having to just include the js in the main script (ugh - had to hard code for tiny..)
          Then just creating a new setup and then making  a call with in the pulled page.. all is good now..

          http://tinymce.moxiecode.com/examples/example_12.php