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

    I have a template, that I have inserted some comments in, just to remember what the code does.
    Is there anyway to get ModX to remove these comments from the final page ?
    I know that the visitor to my page will not actually see the <!-- html comments -->, cause the browser will not show them. But if the user views page source, the comments are there, and i prefer them not being there. Is there any way to achieve this ?

    By the way I am using version 0.9.6.3

    Thanks
      • 10076
      • 1,024 Posts
      Hi,

      I do not know of a utility that does that for you.
      I just do it manually. But maybe others know of such a plugin/snippet?
        • 3749
        • 24,544 Posts
        Here’s a start (although it will remove JS inside comments):

        http://modxcms.com/forums/index.php/topic,2737.0.html
          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
          • 25595
          • 9 Posts
          Hi

          Thank you, just what I am looking for

          Although I am very newb to php. How exactly do I make it work ? Do I save the whole thing in a snippet, or directly in the html template ?

          And how do I assing the OnWebPagePrerender, which they say must be assigned ?


          Kind reagrds
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            It’s a plugin... Resources -> Manage Resources, and the Plugins tab.

            To assign an event, when editing the plugin go to the System Events tab and check the events you want your plugin to use.

            http://sottwell.com/how-plugins-work.html
              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
              • 21257 MODX Staff
              • 730 Posts
              I’ve recently started doing the following for one-line comments if don’t want it in the document output:

              [[//this is my comment]]
              


              It makes use of the parser, which interprets it as a snippet call, but doesn’t find a snippet to run. The double slashes just help me to visually identify it as a comment.
              I don’t think it’s much more overhead for the parser than using a plugin to modify the document output. (It might even be less?)
              You can do this style of comment in the document or in any element that is going through the parser (template, chunk).
                Mike Schell
                Lead Developer, MODX Cloud
                Email: [email protected]
                GitHub: https://github.com/netProphET/
                Twitter: @mkschell
                • 25595
                • 9 Posts
                Thanks alot guys grin