We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25857
    • 23 Posts
    I would like to know if its possible to have comments in template document like Spip. Those comments will be only read by developer or integrator to explain their code (snippet, tv, phx)?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      A MODx template is just HTML, so you can use all the HTML comments you want. Likewise in a document’s content or a chunk. Snippets are PHP, so you can use PHP comments, or have the snippet echo an HTML comment:
      echo '<!-- Comment From a Snippet -->';
        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
        • 25857
        • 23 Posts
        Thanks, but it’s not that I want to explain, HTML comment can be read by everybody in source code in the browser. That I want are comments can be read only by Back-user who works on the template. For example: I use Phx and I want to leave a comment to the person who will work later on this template for understand what I done.
        Like that :
        [(#COM this condition is use for .....)]
        [+phx:if=`[*parent*]`:is=`8`:then=`[[Ditto?&documents=`12`&tpl=`aff_lien`&depth=`1`]]`+]
        


        where "[(#COM this condition is use for .....)]" can only be read by back User.
          • 25663 MODX Staff
          • 12,272 Posts
          Not sure of the performance implications, but you can use "fake" snippets to do this. When snippets aren’t found, MODx just removes them from the output:

          [[DOC: This is some helpful stuff right here. Enjoy! ]]
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 25857
            • 23 Posts
            Tks, I will try and see the performance.
              • 15082
              • 195 Posts
              I think, you’re searching this:
              http://modxcms.com/extras/package/76

              Greetz
              JUSI
                • 16183
                • 1,390 Posts
                Quote from: jusicgn at Sep 10, 2009, 08:58 AM

                I think, you’re searching this:
                http://modxcms.com/extras/package/76

                Greetz
                JUSI
                Hi

                That link leads to a page not found - 404

                What’s the name of the addon pleas? Thanks.

                cheers/k
                  • 15082
                  • 195 Posts
                  ??? for me the link works - funny thing.

                  It’s named "commentTags".

                  Here is the support forum link: http://www.modxcms.com/forums/index.php?topic=13200
                  and here another link to the package http://modxcms.com/commentTags-1389.html

                  Greetz
                  JUSI
                    • 16183
                    • 1,390 Posts
                    Very strange. I am still getting the 404s to all those extras links. I think the extras is down; Searching returns a blank page. Thx anyway.

                    cheers/k
                      • 15082
                      • 195 Posts
                      Really strange...

                      For me it’s still working. Try the direct link: http://modxcms.com/extras/dl.html?file=109

                      If this doesn’t work, here is the content of the file for copy/paste:
                      /**
                       * Plugin: commentTags
                       * Author: Garry Nutting
                       * Version: 1.1
                       * For: MODx 0.9.5+
                       * 
                       * Attach to: OnParseDocument, OnWebPagePrerender
                       */
                      
                      // set the tag nomenclature
                      $commentOpenTag = '[comment]';
                      $commentCloseTag = '[/comment]';
                      
                      // escape special regex characters
                      $commentOpenTag = preg_quote($commentOpenTag,'/');
                      $commentCloseTag = preg_quote($commentCloseTag,'/');
                      
                      // remove comments
                      $output = &$modx->documentOutput;
                      $e = &$modx->Event;
                      
                      switch ($e->name) {
                      	case 'OnParseDocument':
                      	case 'OnWebPagePrerender':
                      		$output = preg_replace('/('.$commentOpenTag.'.*?'.$commentCloseTag.')/ims','',$output);
                      	break;
                      	default:
                      	return;
                      	break;
                      }


                      Here are the descriptions and instructions from the extras site:


                      Description

                      Adds the ability to comment out portions of the site content by using comment/comment tags. Surround the content you want to comment with the tags and the content will be removed from the final output of the MODx generated page.

                      The plugin is designed to run before snippet, chunks, and template variables are parsed - removing any unnecessary processing that may otherwise be carried out. Then, the plugin is run again right before content is sent to the browser to remove any comment tags that may have been included as part of the parsing process.
                      Instructions

                      To install:

                      1. Copy the contents of the text file.
                      2. Paste into a new plugin in the MODx Manager (Resources -> Plugins tab -> Create new plugin)
                      3. Tick the OnParseDocument and OnWebPagePrerender events for the plugin.
                      4. Save the plugin.

                      Code commenting is now activated. The tags used for commenting can be customised in the plugin code to whatever you want them to be.

                      Greetz
                      JUSI