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

    I must be being stupid and don’t know how to search in this forum, it has been a year and I am still unable to find posts related to my question!

    Forgive me if there is already discussions about that, my problem is that I wanted to quote some codes in articles in my MODx site. When I did it, I encountered two issues:
    1. The codes get executed! I simply wanted to show the codes in my article rather than running them.
    2. The "Code" format that TinyMCE supports doesn’t get applied to my quoted codes.
    If I select codes, then change its format to "Code" in the TinyMCE toolbar, then save the document, it didn’t get saved! The only way I could make it work is to manually edit the HTML codes for my documents, which is extremely slow and error-prone.

    Can someone please shed some light on how to resolve those issues for me.

    Regards!
    Johnmen
      • 26016
      • 561 Posts
      Hi,
      If I were trying to show code in a MODx page, I wouldn’t even use Tiny. WYSIWYG editors in web browsers, no matter how good they are, tend to be evil. smiley

      True, you can try using the HTML edit button and all that, but Tiny will add its own code to what you do in a whole lot of situations. It thinks it’s doing you a favor. smiley

      I would suggest editing the page, under Settings uncheck Rich Text, Save, and then edit the page using raw HTML, including <CODE> tags, or whatever makes your code look good. Some manual work, for sure, but if you write code, you might not mind.

      I have a battle with clients all the time who just can’t believe that the WYSIWYG editor can’t do exactly what is in their MS Word document.

      Good luck, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 3749
        • 24,544 Posts
          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
          • 36959
          • 22 Posts
          Thanks you guys for the info. They are useful but I have to say won’t sort out my issue. As I try to avoid doing the manual HTML editing which slows me down heavily when editing documents, plus you can easily make typos without even knowing it.

          What I would like to see is some sort of automatic or semi-automatic way to make it happen. Looking into the forum here, there are heaps of posts that have got the codes quoted. I just don’t believe they were all manually edited in HTML codes. Update: I might be wrong as this forum is based on SMF instead of MODx as far as I understand, hence quoting codes will be done differently.

          Regards!
            • 3749
            • 24,544 Posts
            With the plugin, you just put <fixedpre></fixedpre> tags around the code you want to display rather than execute. Everything else is automatic.

            You don’t have to use those tag names, either. You could change it to <x></x> if you’d like to cut some keystrokes.

            If you don’t want the code to execute, you’re going to have to identify it somehow and I can’t imagine any other process that would be less work. If you have one in mind, I’d definitely like to hear it.
              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
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Is there any reason you couldn’t configure this to use <code>...</code> tags?
                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
                • 3749
                • 24,544 Posts
                Quote from: sottwell at Apr 12, 2010, 10:56 PM

                Is there any reason you couldn’t configure this to use <code>...</code> tags?

                The only reason I can think of is that it removes the tags (I think) so any CSS based on those tags wouldn’t work -- and it would remove <code></code> tags on other documents.
                  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
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Ah, I see. And I suppose it is possible that somebody would want to have a MODx tag actually processed inside of <code> tags.
                    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