We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21054
    • 78 Posts
    I’ve set up a blog using Ditto/Jot and decided that I only wanted certain posts to enable/display commenting.

    I did a bit of reading here, and decided to use the ChunkIf snippet (http://modxcms.com/forums/index.php/topic,5528.html) to create a check box TV called "showComments" (yes, I have selected the correct template to allow access to the TV tongue). I have no default or option values set up.

    I call the snippet like this:

    [[ChunkIf? &tv=`showComments` &trueChunk=`Comments` &falseChunk=``  &debug=`0` ]]


    From the blog entry, I check the showComments check box and save... but nothing! I try unchecking the box and saving... and it reverts back to checked.

    If I make &falseChunk=`Comments` the comments appear.

    If I set debug to 1, I don’t get any data to help me troubleshoot.

    Any ideas?

    Thanks a bunch smiley
      • 7231
      • 4,205 Posts
      Here is a tutorial that illustrates how to do this by building a custom snippet:
      http://modxdeveloper.com/blog/check-box-tv-toggle-display

        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27708 MODX Staff
        • 2,502 Posts
        You could do this with PHx or the If Snippet.

        All you want to do is check to see if a showComments is set and if it is display the jot call, if not, display nothing or something like comments are disabled for this post.

        If you have PHx installed and you tv is showComments you do do:
         [*phx:if=`[*showComments*]`:is=`1`:then=`{{Comments}}`:else=``*]


        The If snippet is similar (I didn’t test this and I don’t remember if the syntax is 100%):
        [[If? &subject=`[*showComments*]` &operator=`equals` &operand=`1` &then=`{{comments}}` &else=``]]
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 21054
          • 78 Posts
          Thanks guys... I’ll test these methods out.

          Didn’t know about PHx by the way... looks like this sort of thing needs to be a part of the MODx install smiley
            • 24732 ☆ A M B ☆
            • 300 Posts
            just fyi, I used the ChunkIf snippet to do exactly this, you have to set a value in "Input Option Values" in the checkbox TV form when you create the template variable. If there is not value set in that field then you will get the results you described, I did the same thing. Putting "show" in the field fixed it.
              ________

              Anne
              Toad-in-Chief
              Red Toad Media - Web Design, Louisville KY
              Hear me tweet: http://www.twitter.com/redtoadmedia
              "Bring on the imperialistic condiments." - Rory Gilmore