We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36605
    • 70 Posts
    Sooo this has been one thing that -back when I was first learning ModX evo- completely baffled me as I had no real understanding of TVs. However, now much more learned and even making some semi-basic snippets of my own, TinyMCE has been confusing me once again.

    For starters, I’m not using NewsPublisher as I didn’t want to have to deal with going into the code to change labels so that FE admins don’t have to worry with ModX lingo for inputs. Instead, I’ve got my form setup with Title, Headline, Content, and image inputs all heading into FormIt. However, my RT tv for the content just won’t display TinyMCE. I’ve tried searching the forums and google (which IMO seems to actually work much better for searching), and this is the most useful thread I found: http://modxcms.com/forums/index.php/topic,57047.0.html

    That’s from November 2010. I tried looking at the ModX wiki and RTFM for TinyMCE but saw no insights into this problem of mine. Is there some insight I’m missing, or has this still not been fully addressed in the TinyMCE port? If you guys could enlighten me with some help, that’d be awesome embarrassed

    And lastly, I just want to say I’ve been using ModX for a good long time now though pretty inactive here for most of the CMS’s growth. It’s awesome to see it reach the point it has, and thank you all for helping to contribute to the growth of this system smiley
      • 3749
      • 24,544 Posts
      FYI, you can change the captions for any of the fields in Lexicon Management and use NewsPublisher, FrontPage, or formit2Resource in the front end. I think TinyMCE works in all three.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36605
        • 70 Posts
        For clarification purposes, I am currently using formit2resource but having trouble with the TinyMCE nonetheless.


        And Lexicon Management has been one area I haven’t really gotten into still. But with MCE, what’s the proper way to configure the TV for front-end input then? Because every configuration seems to just not end up with it showing for me.

        Edit: I tried to go into NP lexicon but didn’t see a place for title and longtitle? I don’t want to change it for the backend as I’m the only one using it, and it’s only for a portion of the site.

        2nd edit: forgot to say thanks for the help thus far
          • 3749
          • 24,544 Posts
          NewsPublisher uses the lexicon strings in the core namespace for the resource field captions. Changing them would change them in the manager too, though. Of course the TV captions are the ones you enter when you create or edit the TV itself.

          Does TinyMCE show up for your rich text TVs when you edit a resource in the Manager?

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 3749
            • 24,544 Posts
            NewsPublisher uses the lexicon strings in the core namespace for the resource field captions. Changing them would change them in the manager too, though. Of course the TV captions are the ones you enter when you create or edit the TV itself.

            Does TinyMCE show up for your rich text TVs when you edit a resource in the Manager?

            I think you have to specify the proper class the your input fields in your Tpl chunk for TinyMCE to operate in the front end. IIRC, it’s

            <input class="modx-richtext" . . ..


              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 36605
              • 70 Posts
              So TinyMCE is working with NewsPublisher but not with my form, which is what I’d much rather be using so as not to deal with the whole lexicon issue.

              Also, it does show up as the richtext TV while in the manager. I also went looking through the page’s output and noticed that none of the js includes for tiny were being executed by ModX. I tried looking up the include codes that appear in the source from my newspublisher page and copying them into a snippet to execute beforehand, but it kept getting errors. Is there something in the config that I can make Tiny initiate on a standard page? I don’t know all the details in it’s templating so It’d be awesome if somehow I’d just be able to initiate an instance using the settings from the backend.
                • 36605
                • 70 Posts
                Update:
                So in frustration, and in trying to be as competent a programmer as I can be I went to the TinyMCE website and found this basic call from a example on how to use it in php. THIS did work to an extent, as it did give me a TinyMCE instance where I asked (changing the element name of course), however it does that somewhat buggily. Also, with that, by putting it in my form, everything under it becomes part of the instance (including the rest of the form, AND the site footer).

                Code of basic TinyMCE call:
                <script language="javascript" type="text/javascript">
                  tinyMCE.init({
                    theme : "advanced",
                    mode: "exact",
                    elements : "elm1",
                    theme_advanced_toolbar_location : "top",
                    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,"
                    + "justifyleft,justifycenter,justifyright,justifyfull,formatselect,"
                    + "bullist,numlist,outdent,indent",
                    theme_advanced_buttons2 : "link,unlink,anchor,image,separator,"
                    +"undo,redo,cleanup,code,separator,sub,sup,charmap",
                    theme_advanced_buttons3 : "",
                    height:"350px",
                    width:"600px"
                });
                
                </script>



                So my question is: it seems easy enough to link to all the right files, but What is the proper way to initiate TinyMCE as it doesn’t do it standard in the Front-end?
                  • 4172
                  • 5,888 Posts
                  you can do this:
                  create a snippet ’tinymceFe’ with this code (this is from newspuplisher)

                  <?php
                  
                  $props = $scriptProperties;
                  
                  /* set rich text content placeholders and includes necessary js files */
                  $tinyPath = $modx->getOption('core_path') . 'components/tinymce/';
                  $modx->regClientStartupScript($modx->getOption('manager_url') .
                      'assets/ext3/adapter/ext/ext-base.js');
                  $modx->regClientStartupScript($modx->getOption('manager_url') .
                      'assets/ext3/ext-all.js');
                  $modx->regClientStartupScript($modx->getOption('manager_url') .
                      'assets/modext/core/modx.js');
                  
                  
                  $whichEditor = $modx->getOption('which_editor', null, '');
                  
                  $plugin = $modx->getObject('modPlugin', array('name' => $whichEditor));
                  if ($whichEditor == 'TinyMCE') {
                      //$tinyUrl = $this->modx->getOption('assets_url').'components/tinymcefe/';
                      $tinyUrl = $modx->getOption('assets_url') . 'components/tinymce/';
                      /* OnRichTextEditorInit */
                  
                      $tinyproperties = $plugin->getProperties();
                      require_once $tinyPath . 'tinymce.class.php';
                      $tiny = new TinyMCE($modx, $tinyproperties, $tinyUrl);
                      // if (isset($this->props['forfrontend']) || $this->modx->isFrontend()) {
                      if (isset($props['forfrontend']) || $modx->context->get('key') !=
                          'mgr') {
                          $def = $modx->getOption('cultureKey', null, $modx->getOption('manager_language', null,
                              'en'));
                          $tinyproperties['language'] = $modx->getOption('fe_editor_lang', array(),
                              $def);
                          $tinyproperties['frontend'] = true;
                          unset($def);
                      }
                      $tinyproperties['cleanup'] = true;
                       /* prevents "bogus" bug */
                      $tinyproperties['width'] = empty($props['tinywidth']) ? '95%' : $props['tinywidth'];
                      $tinyproperties['height'] = empty($props['tinyheight']) ? '400px' : $props['tinyheight'];
                  
                      //$tinyproperties['tiny.custom_buttons1'] = 'image';
                      //$tinyproperties['tiny.custom_buttons2'] = '';
                  
                      $tiny->setProperties($tinyproperties);
                  
                      $html = $tiny->initialize();
                  
                      $modx->regClientStartupScript($tiny->config['assetsUrl'] .
                          'jscripts/tiny_mce/langs/' . $tiny->properties['language'] . '.js');
                      $modx->regClientStartupScript($tiny->config['assetsUrl'] .
                          'tiny.browser.js');
                      //mod by Bruno
                  
                      if ($props['hasimagetv']) {
                          $rt_configs = array("selector" => "rt_imagetv", "width" => $props['imageTvWidth'],
                              "height" => $props['imageTvHeight'], "buttons1" => "image", "buttons2" => "",
                              "theme_advanced_buttons1" => "image", "theme_advanced_buttons2" => "", );
                  
                          $cfg = '';
                          foreach ($rt_configs as $cf_key => $cf_value) {
                              $cfg .= 'Tiny.config.' . $cf_key . ' = "' . $cf_value . '";';
                          }
                          $js .= $cfg . ' MODx.loadRTE();';
                      }
                  
                      $modx->regClientStartupHTMLBlock('<script type="text/javascript">
                                         Ext.onReady(function() {
                                         MODx.loadRTE();
                                         ' . $js . '
                                         });
                                     </script>');
                  
                  }
                   /* end if ($whichEditor == 'TinyMCE') */
                  


                  and use it like that:

                  [[!tinymceFe]]
                  
                  <textarea name="content" class="modx-richtext">
                  </textarea>
                  


                  that’s it.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 36605
                    • 70 Posts
                    Thanks, but where is that in NewsPublisher? I searched that snippet up and down (even with the the broswer’s find tool) and didn’t find anything on it in there. Is it placed somewhere else?

                    And also, do you know why that hasn’t been made into part of the TinyMCE plugin itself?
                      • 3749
                      • 24,544 Posts
                      I originally included that as part of the NP package, but Tiny was rewritten to work in the front end so I took it out. I have not had time to test the current version of TinyMCE with the current version of MODX, so there may be some issues.

                      Did I mention that I really hate TinyMCE? wink
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting