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

    since there is no comment tag in modx, this is my wish for upcoming versions of modx.

    See: http://modxcms.com/forums/index.php/topic,13120.0.html

    I wonder why nobody seems to miss such a comment tag...obviously everybody just deletes (currently) unneeded chunks of code.... rolleyes

    Generally I prefer to comment out code and have it still "there" instead of searching for it in other places. This option would be very handy particularly with regard to modx beginners, who use a standard template and want to disable unneeded features, without deleting them.


    Greetings,
    CoreBit
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: CoreBit at Mar 17, 2007, 09:41 AM

      I wonder why nobody seems to miss such a comment tag...obviously everybody just deletes (currently) unneeded chunks of code.... rolleyes
      Just prefix the name of the snippet/chunk etc. so it is no longer called with a valid name, i.e. {{activeChunk}} changed to {{_activeChunk}} would serve the same purpose you are trying to accomplish (i.e. keep the tag in the source without it executing or being left in the output). This is much less work than surrounding tags with another tag and adding overhead to the parser so it is aware of such entities.
        • 7455
        • 2,204 Posts
        Thats the way I do it also, I always prefix the snippet or chunk with off_ that way there is no parsing and just a empty void where normaly the output apears.

        Dimmy
          follow me on twitter: @dimmy01
          • 5798
          • 22 Posts
          Thanks for that hint! grin But that doesn’t solve the problem I meant. With your trick I can only "comment out" modx-calls (chunks, snippets,..). But you can’t comment out the surrounding html-code the modx-call is embedded in. undecided
          That part can only be made invisible with <!-- --> and therefore gets still transferred to the browser which is no clean solution!

          I don’t know many other CMS, so I can’t say, if there are always comment-tags. But I use Interchange and the comment-tag there is probably the most used tag of all! (Most Interchange users start off the full featured standard shop and disable as many features as they don’t need to go online. Then they put back one feature after another, as they learn, how to use it.)

          Well, modx is surely much easier to understand and to get used to (great work!!!). Still I find that a comment-tag would make modx a bit more "complete"...

          Greetings,
          CoreBit
            • 10487 MODX Staff
            • 1,535 Posts
            Well, you could do with creating a plugin to do the job, shouldn’t be too hard to create something that uses preg_replace() to strip out the desired commented areas.

            Attach it to one of the events before parsing happens (OnParseDocument for example) and then perhaps right before the final output is rendered to screen (OnWebpagePrerender) to capture any comment tags that may have been added due to snippet/chunk parsing etc.
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 5798
              • 22 Posts
              Wow, writing a plugin for modx is FAR beyond the scope of my modx skills. I use that great CMS for just a few weeks now and still keep struggling to finish my private homepage with it... wink

              Maybe I’ll be able to code things like plugins in a few months...but by that time it could have been done already by one of the developers, that’s why I proposed it for the wishlist. smiley

              Greetings,
              CoreBit
                • 10487 MODX Staff
                • 1,535 Posts
                I’ll see if I can help you out with an example plugin ... bear with me and I’ll try and do it tonight. smiley
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 10487 MODX Staff
                  • 1,535 Posts
                  Okay, here you go smiley ... add the code below as a new plugin and make sure you tick the "OnParseDocument" and "OnWebPagePrerender" checkboxes under the System Events tab for the plugin. Then, you can comment out sections of code by using: [comment] comment this out [/comment]

                  EDIT: The forum seems to be screwing some of the code, replace %body%#039; with $ ’ but remove the space between those two characters.

                  Feel free to modify this in any way you want.

                  SECOND EDIT: The plugin is now available in the MODx repository: http://modxcms.com/commentTags-1389.html
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 7923
                    • 4,213 Posts
                    I think it would be good to have this in resource repo if it works alright.. Good stuff!


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 5798
                      • 22 Posts
                      Thank you for your efforts, garryn! I tried the code you gave me for the plugin and setup everything as you described.

                      The following section inside my MODxHost template still gets displayed and I can see the comment tags, too:

                      [comment] <!-- <h2>News:</h2> -->
                                  [[Ditto? &startID=`2` &summarize=`2` &total=`20` &commentschunk=`Comments` &tpl=`nl_sidebar` &showarch=`0` &truncLen=`100` &truncSplit=`0`]] [/comment]


                      Did I miss something?

                      Greetings,
                      CoreBit