We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34127
    • 135 Posts
    Hi guys. Just wondering: is it possible to make TinyMCE parse MODX placeholders? Eg. turn "[[++assets_url]]" into "path/to/assets/"?

    Basically, what I'd like to do is host all of my static content on a [cookie-less] subdomain. This is fine for CSS and JS, but adding the [[++assets_url]] prefix to all of my images results in images showing up as broken in the RTE, as it's not replacing the placeholder with the value of the system setting.

    Of course, I could just point my images at the direct URL, but I'd like to know if the first option is possible.

    Thanks! smiley
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      No, TinyMCE cannot parse MODx tags. Images in .css files can be linked relative to the .css file. For example, if your images folder is in the same place as the .css file, image paths would look like
      #something {background:url(images/someimage.png)top center no-repeat;}


      If the .css file is in a "css" folder and the images are in an "images" folder in the same place, then it would look like
      #something {background:url(../images/someimage.png)top center no-repeat;}
        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
        • 34127
        • 135 Posts
        Thanks Susan. I can't really use CSS for this. My site contains articles, how-to's, etc with quite a few pictures. So, I'd like to do something like:

        <img src="[[++assets_url]]path/to/image/myimage.jpg" />


        The assets_url placeholder would be replaced by the system setting (but not really replace - TinyMCE would just render the image with the real content of the system setting. So Tiny would show the image at:

        http://some-subdomain.my-domain.com/path/to/image/myimage.jpg


        I wonder if a callback function might do the trick?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah, sorry. I misunderstood. I have done much the same, only using a chunk to provide the common part of the URL.

          http://domain.com/where/images/are/


          then my image link just looks like [[$imageURL]]image.jpg
            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
            • 34127
            • 135 Posts
            That's a good idea! But the image would still show up as broken in TinyMCE.

            Still, it'd be nice to get Tiny to render MODX tags (at least the assets_url system setting). But then again, that opens a can of worms with output modifiers. Those tags could just be ignored, though, seeing as parsing MODX tags is outside the scope of TinyMCE. I'll look into TinyMCE's callback functions and see if I can come up with something.
              • 39194
              • 149 Posts
              Hm, this is interesting subject. I'll think about this feature... I'm going to make CKEditor transport package...
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                I still much prefer the elRTE editor and the related elFinder file manager. A package for elRTE was made some time ago, but it was rather rudimentary and didn't take into account most of the relevant MODx settings. I've often thought it a pity that elFinder wasn't made into a package. Its image editing features are excellent, among other almost excessive features. Hook it up with Media Sources and it would be fantastic. Written with JQuery.

                Consider how easy it would be to connect it to Media Sources: https://github.com/Studio-42/elFinder/wiki/Multiple-Roots [ed. note: sottwell last edited this post 13 years, 10 months ago.]
                  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
                  • 34127
                  • 135 Posts
                  @danya_postfactum - That sounds great! smiley

                  There was a package for CKEditor when Revolution was in its early 2.0 version, and I really liked it. The 4.0 beta looks really clean and neat and it produces nice valid code. I'd definitely like to see it integrated into the manager!

                  @susan - elRTE also looks really good. It loads quite fast, lots of options and features, and the fact that it uses jQuery is a big plus. But it was updated almost a year and a half ago.. is it still actively developed?
                    • 39194
                    • 149 Posts
                    Quote from: sottwell at Nov 25, 2012, 08:39 PM
                    Written with JQuery.

                    I don't like It...

                    You can try my first attempt of CKE integration (I have named it Semantics because I intended to rewrite engine completely) - semantics-1.0-beta.transport.zip

                    This supports d'n'd from the trees. Uses Ace for source highlighting. But it requires much time to finish my work. I'l have a look at 4.0 version )