We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33033
    • 43 Posts
    Just tried it on mine and it worked great.
    @CoreBit - Did you select OnParseDocument and OnWebPagePrerender in the System Events tab for the plugin? That was the only way I duplicated your problem.
      • 5798
      • 22 Posts
      Doh! Since the fonts of the manager theme "MODxLight" were so tiny, I didn’t see the error in this line:
      $escapeChars = array('.','\\','/','+','*','?','[','^',']','$;,'(',')','{','}','=','!','<','>','|',':');


      After copying out the whole plugin code into an extern editor, I recognized it. Now the comment tag works fine!
      Thanks for the great work, garryn!

      Greetings,
      CoreBit

      PS: To be on the safe side, I changed the manager theme to MODxGreen, too... wink
        • 10487 MODX Staff
        • 1,535 Posts
        Cool, I’ll get it added into the repository smiley
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 27376
          • 576 Posts
          Those with php4 and up can replace:
          // escape special regex characters
          $escapeChars = array('.','\\','/','+','*','?','[','^',']','%body%#039;,'(',')','{','}','=','!','<','>','|',':');
          foreach ($escapeChars as $value) {
          	$commentOpenTag = str_replace($value,'\\'.$value,$commentOpenTag);
          	$commentCloseTag = str_replace($value,'\\'.$value,$commentCloseTag);
          }
          with this:
          $commentOpenTag = preg_quote($commentOpenTag);
          $commentCloseTag = preg_quote($commentCloseTag);
          

          The [tt]preg_quote()[/tt] function was introduced in php4 and was designed specifically for this purpose smiley

          Enjoy!
            • 25663 MODX Staff
            • 12,272 Posts
            Since there’s a distinct probability that other stuff will break in PHP <4.3.x ... would it make sense to just use that period?
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 10487 MODX Staff
              • 1,535 Posts
              Yeah, absolutely. Lol, I forgot all about preg_quote() in my eagerness to get the plugin out ... not that it makes much difference in this instance. I’ll get the code updated though.

              EDIT: Oh, and in this case, the correct preg_quote() usage would be along the lines of preg_quote($commentOpenTag,’/’) so that the delimiter is taken into account as well.
                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com