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

    I want to disable comments for specific posts.
    How can that be achieved?

    Thanks
    • Good question. I don't see any way to do that either.
        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
        • 34090
        • 16 Posts
        What do you think about a checkbox (template variable) for each article and a [[IF]] validation?
        I think that should work as a temporary solution.
          • 34120
          • 236 Posts
          Hi, any change on this?

          I'm removing the comments by editing them out in the ArticleTemplate. Just wondering if I've missed a setting somewhere?
            • 34090
            • 16 Posts
            Hi bobwal,

            I didn’t have time to play around with this anymore. I think I should read the changelog on this. Maybe it works now.
              • 33990
              • 23 Posts
              I don't think there is a way to do this (as of Articles 1.4.7).

              It would be great if there was a way to disable and/or close comments on individual posts. Has anybody found a way of doing this, e.g. through using TVs?
                • 38000
                • 19 Posts
                Damn... by coincidence I deleted my own reply. Just because... I wanted to change another linebreak tag in html which they deleted... #sigh...

                Make things short:

                Disabling comments

                There are two ways (maybe a lot more).

                1) Use different tpls. Make a tpl newsWithComments and another one newsWithoutComments or whatever you want to name them. In the newsWithComments you put the Quip- and QuipReply-Code in the other one not.

                2) Using a tv. I'd say radio options would be okay. useCommentsTV (yes=1||no=0).

                Then you have to change your newsArticleTpl like follows:

                [[+useCommentsTV:isnot=`0`:then=`[[!Quip]]br-tag[[!QuipReply]]`


                The latter needs less resources at the editor's side - only clicking once instead of twice for the drop down changing the tpl. The first needs less resources when you think as an admin of a web server. The parser and modx don't have to check every time when a user visits the page what value the tv has and output the result according. Would not be a big gain in web server's resources but might be more efficient just on principle.

                The br-tag should be the html one but the system abandoned it though I chose "code" as a format option in my first post.

                Closing comments

                There is a filter for QuipReply named closed if you set this to 1 with a tv everything should work for you. You are free to chose which kind of tv you want. I'd say radio options would be okay as well. Again you chose yes = 1 and no = 0 and well name it perhaps disableCommentsTV.

                Then you put this into your tpl:

                [[!Quip]]
                br-tag
                [[!QuipReply
                &thread=`**`
                &closed=`[[+disableCommentsTV]]`
                ]]


                Did not try this out myself though I think it should work.
                  • 33990
                  • 23 Posts
                  Hi gameship - thanks for your ideas. The only problem is I can't see any calls to Quip from within any of the Articles templates or settings. All the templates include are Articles placeholders e.g.
                  [[+comments]]


                  Any idea where/how I might be able to pass arguments through to the Quip call from within articles?

                  In the meantime, I've used your suggestion of a duplicate template e.g. ArticleTemplateCommentsClosed - which has all the same mark-up except the
                   [[+comments_form]]
                  placeholder has been replaced by a paragraph saying "comments are now closed". While I'd prefer to control this with a TV the alternate blog template is a useful work-around smiley
                    • 38000
                    • 19 Posts
                    Ah okay. I thought you had your own templates used.

                    This
                    [[+comments]]
                    is a chunk that is provided with the articles snippet but goes back to Quip itself. It is like a default tpl for the comments to output (cf. http://rtfm.modx.com/display/ADDON/Quip.Quip.tplComments).

                    The
                    [[+comments_form]]
                    is the one with the code in it to reply to a comment.

                    So you have two choices now: exchange these comments and comments_form with the Quip and QuipReply but this would make more sense if you'd have your own tpls. I don't know about the articles tpls and how these inherit some tags that might get broken if you change something.

                    In that case you would have to think a bit differently about the last solution I presented for "closing comments". So you have to think like this: If +comments shows the list of comments already made, and if comments_form is only representing the form making a new comment what do I need to do, to suspend users from commenting?

                    It is that you have to not output the comments_form. Then you make use of another tv. To check for this you could use a template variable with radio options as well. Yes is 1 and no is 0.

                    //excursion

                    Whenever you want something hidden or shown you could make use of tvs in a way like this.

                    //excursion end

                    Name your tv like you want, I'd say something like closeCommentsTV would do fine. So you change the input type to radio options, better to say "radio buttons" (it's called like that in the manager). Then there is the field for input options of the tv. There you have to put in those options you wanted to be choosable. Every single option is separated by these two vertical lines ||. If it's only two options it would recur to yes and no, and then you would type

                    yes=1||no=0


                    It really does not matter what kind of names you chose but if you chose some that "speak", so to say, they help you understand what the whole thing does. So you ask the question "Do I/you (the editor) want to close the comments?" The TV represents the answer to your question therefore I chose yes and no.

                    Now think of the answer "Yes" I want to close comments. What do you have to do to achieve this goal? ... No longer show the "respond to comment" (which is comments_form). Hence you should first create the tv as I mentioned above and then change the "template" like follows. Instead of

                    [[+comments_form]]


                    you write

                    [[*closeCommentsTV:isnot=`1`:then=`[[+comments_form]]`:else=``]]


                    So to translate this into words... it would be "Do you think that comments_form (possibility of commenting) should not be shown?" If your answer is yes, you would interpret like "Yes" I don't want the comments to be closed otherwise they should and then you output nothing. It is important though that you replace the comments_form with the code I posted above.

                    I often formulate those conditions in a negative way with "isnot". It's because you can check the case which is less often used.

                    If you put it like "isnot=1" this would be translated like "If I don't want to close Comments" then I output the comments_form. Otherwise (if you chose no and the value of the variable is 0) the comments_form is not output.

                    Update: What I forgot to mention. "If" you change those standard tpls for Articles and you do an update of the Articles snippet then those tpls will be overwritten. You hence should think of making your own tpl or at least you have to change this line of code every time you update your Articles snippet. [ed. note: gameship last edited this post 12 years, 2 months ago.]