We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42562
    • 1,145 Posts
    RE: robcarey

    To speak plainly, sir, I think there be a demon in that thing. MODX + that Editor causes untold rise of that maniacal entity.

    Sorry for not having an answer at hand. I believe I have tried almost everything MODX-wise.

    I can create a plugin to fix that, but that would be another time. [ed. note: donshakespeare last edited this post 7 years, 2 months ago.]
      TinymceWrapper: Complete back/frontend content solution.
      Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
      5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
      • 3749
      • 24,544 Posts
      @donshakespeare: Not a TinyMCE Wrapper question, per se, but since you're the expert: do you know any way to pass dynamic baseURL and basePath params through TinyMCE to elFinder? (This is in NewsPublisher.)

      With TVs, they are based on the Media Source and can be different for each TV. With standalone file and image TVs, I've got a method that works, and I can set them for all instances of TinyMCE with properties, but it would be nice if it could work in a Richtext TV when you launch elFinder from TinyMCE.

      When launched from TinyMCE, elFinder has no way of knowing if it's dealing with a TV or which TV it is.
        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
        • 42562
        • 1,145 Posts
        RE: BobRay

        I have an idea for Media Sources recently.
        The code you posted on github is that the code you are using?
        I will work something for TinyMCE. I'll post here shortly.

        Cheers
          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 42562
          • 1,145 Posts
          RE: BobRay

          I intend to ship this long-sort feature with TinymceWrapper's next release.
          Here is how to tell elFinder what is the origin of request:

          1) Add a TV url parameter and vary the value depending on what is making the request; and then check against the TV existence/value in the elFinder connector PHP config
          www.example.com/elfinder.html?tv=22&res=109
          www.example.com/elfinder.html?tv=<? echo $tvID; ?>&res=<? echo $resourceID; ?>
          www.example.com/elfinder.html?tv=[[!tvID]]&res=[[*id]] //MODX snippet and/or placeholde
          "www.example.com/elfinder.html?tv="+tvID+"&res="+resourceID //JavaScript
          www.example.com/elfinder.html?tv=0&res=0 //request made by RTE or other than TV
          www.example.com/elfinder.html  //request made by RTE or other than TV
          


          2) Note! The url parameter must be redeclared via JS in the elfinder.html (or elfinder.php) before it can then be passed to the elFinder connector.
          Here is an example elfinder.html (MODX Resource). If using raw PHP, then that snippet (getUrlParam) call is even easier
          //elfinder.html
          <html>
            <body>
            <!--etc etc-->
            $(document).ready(function() {
              $('#elfinder').elfinder({
                customData : {
                  tv: "[[!getUrlParam? &name=`tv` &default=`0` &int=`1`]]", //grab TV id from url and pass to connector.php
                  res: "[[!getUrlParam? &name=`res` &default=`0` &int=`1`]]" //grab Resource id from url and pass to connector.php
                  //more
                },
                //more
              });
            });
            </body>
          </html>


          3) From 2) you will have a nice tv parameter passed on to the elFinder connector, which you may clean up and grab as you please.
          From here you may be more elaborate, there is the gist
          //connector.php
          $tv = $res = $context = "";
          
          if(isset($_GET["tv"]) && !empty($_GET["tv"])){
            $tv = $_GET["tv"]; //force to be integer
          }
          
          if(isset($_GET["res"]) && !empty($_GET["res"])){
            $res = $_GET["res"]; //force to be integer
          }
          
          
          if($tv && $res){
            $context = $modx->getObject("modResource", $res);
            $context = empty($context) ? 'web' : $context->get('contextKey');
            $tvObj = $modx->getObject('modTemplateVar', $tv);
            $source = $tvObj ->getSource($context, false);
            $properties = $source->getProperties();
            $basePath = $properties['basePath']['value'];
            $baseURL = $properties['baseUrl']['value'];
          }
          else{
            $basePath = "~path/assets/folder/"; //non TV request
            $baseURL = "/assets/folder/"; //non TV request
          }
          
          $opts = array(
           'roots' => array(
            array(
             'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
             'path'   => $basePath, // path to files (REQUIRED)
             'URL'    => $baseURL, // URL to files (REQUIRED)
            )
           )
          );
          
          // run elFinder
          $connector = new elFinderConnector(new elFinder($opts));
          $connector->run();
          

          [ed. note: donshakespeare last edited this post 7 years, 2 months ago.]
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 42562
            • 1,145 Posts
            Updated above code to pass also resource ID, so that you can get the resource context in elFinder
              TinymceWrapper: Complete back/frontend content solution.
              Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
              5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
              • 3749
              • 24,544 Posts
              Very nice. I'm already doing exactly that with image and file TVs using $source->getBases(). But I hadn't thought of passing the TV ID through TinyMCE that way. Thanks!

                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
                • 42562
                • 1,145 Posts
                I am glad that led somewhere smiley
                  TinymceWrapper: Complete back/frontend content solution.
                  Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                  5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                  • 47717
                  • 144 Posts
                  Quote from: donshakespeare at Feb 09, 2017, 10:29 PM
                  RE: robcarey

                  To speak plainly, sir, I think there be a demon in that thing. MODX + that Editor causes untold rise of that maniacal entity.

                  Sorry for not having an answer at hand. I believe I have tried almost everything MODX-wise.

                  I can create a plugin to fix that, but that would be another time.

                  Hi,

                  The demon just magically disappeared, after some Tibetan visualization just last week ... Weird wink

                  Another (maybe stupid) question: where can I add simple defined "css classes" from my css file to be able to use by "click" in the editor ?

                  So when one selectes a word, and clicks on the menu with the classes, and choses one "css class", that element is wrapped with that css- class

                  THANKS for your great work !
                    • 47717
                    • 144 Posts
                    Quote from: donshakespeare at Jul 16, 2015, 10:09 PM
                    Yup, you may safely remove the old chunks.
                    Only make sure you have backed up the changes you made in order to re-implement them within the new version.

                    Consider also: duplicating all the chunks, retain their original names, but add a suffix, e.g. TinymceWrapperContent-suf, or TinymceWrapperContentHacked
                    Then open the plugin, go to default properties -> chunkSuffix, enter -suf or Hacked
                    In this way, you get to survive the dictatorial tendencies of upgrades.

                    Please test with your Articles container and child pages, do the RichTVs remain activated even when RTE is disabled for that resource? I remember you and some complained about this issue.

                    Hi,

                    I follwed this technique, and the editor still works.
                    HOwever, the "auto detection" of "css, html, js" stops working in other pages. So basically the "code editor" stops working after this.
                    So I disabled this "suffix".
                    What can I do to use this suffix, and still keep all functions ?

                    thanks !
                      • 42562
                      • 1,145 Posts
                      RE: ananda

                      1)
                      ...However, the "auto detection" of "css, html, js" stops working in other pages. So basically the "code editor" stops working after this.
                      So I disabled this "suffix".
                      What can I do to use this suffix, and still keep all functions ?

                      If you are using chunkSuffix, you have to alter the name of your Ace/CodeMirror chunks
                      TinymceWrapperAce-suffix
                      TinymceWrapperCodeMirror-suffix

                      BTW, next release sports some delicious improvement to these Code Editors - thus delivering the best experience on the planet wink



                      2)
                      Another (maybe stupid) question: where can I add simple defined "css classes" from my css file to be able to use by "click" in the editor ?
                      So when one selects a word, and clicks on the menu with the classes, and chooses one "css class", that element is wrapped with that css- class

                      Here is the official thingy with live demo. (if you have specific questions, fire away smiley )
                      https://www.tinymce.com/docs/demo/format-custom/
                      tinymce.init({
                        ..., 
                        style_formats: [
                          { title: 'Bold text', inline: 'strong' },
                          { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
                          { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
                          { title: 'Badge', inline: 'span', styles: { display: 'inline-block', border: '1px solid #2276d2', 'border-radius': '5px', padding: '2px 5px', margin: '0 2px', color: '#2276d2' } },
                          { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
                        ],
                        formats: {
                          alignleft: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'left' },
                          aligncenter: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'center' },
                          alignright: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'right' },
                          alignfull: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'full' },
                          bold: { inline: 'span', 'classes': 'bold' },
                          italic: { inline: 'span', 'classes': 'italic' },
                          underline: { inline: 'span', 'classes': 'underline', exact: true },
                          strikethrough: { inline: 'del' },
                          customformat: { inline: 'span', styles: { color: '#00ff00', fontSize: '20px' }, attributes: { title: 'My custom format' }, classes: 'example1' },
                        },
                        content_css: [
                          '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
                          '//www.tinymce.com/css/codepen.min.css'
                        ]
                      });


                      Cheers.
                        TinymceWrapper: Complete back/frontend content solution.
                        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.