Help - Search - Members - Calendar
Full Version: Closing comments on ALL entries at once
Movable Type Community Forum > Additional Resources > Tips and Tricks
Muffinboy
I want to use the 2.6 option to close commenting on ALL current posts...

The only way to do this MT seems to offer is to go into each individual entry, reset the comments option and save it.

Is there really no way to do some mass conversion of the comments option?
persnit
Other than going into the configuration of the blog and turning comments off that way, no, I don't believe there is any other way to do it.  I would love to have more options on how to control comments!!
crys
QUOTE
Other than going into the configuration of the blog and turning comments off that way, no, I don't believe there is any other way to do it.  I would love to have more options on how to control comments!!

Actually that doesn't work either -- the blog config is only a default nothing to do with current entries...

I think it's one of the items in power edit mode though
Muffinboy
It's not in the power editing mode either.

I don't really feel like going through 900 odd posts to set them all individually to closed comments.

Since I'm running on MySQL now, would there be any way to run a little script on the DB to close all current posts?
medic119
I asked for that about a week ago without results, but it would be nice to have a little PHP Script that would Close all the Coments after a certain number of days (configurable inside the script?) via an SQL statement. All you would have to do would be to run the script from time to time and all your old comments would be closed out.

If my PHP skills were anything above 0, I could probably hash it out.
tubedogg
Your wish is granted.
kadyellebee
Hmmm, that link doesn't seem to work!

Kristine
girlie
It does now.  ;)
tubedogg
Heh, whoops, did I forget the t/ (I'm assuming)? My bad. :0
kadyellebee
Yay!  Thanks, I look forward to checking this out, even though I don't have a place to use it (yet). smile.gif

Kristine
girlie
QUOTE
Heh, whoops, did I forget the t/ (I'm assuming)? My bad. :0

Yep.  ;)
tubedogg
QUOTE
Yay!  Thanks

You're welcome. smile.gif

Please note I have updated the entry at my site to reflect the license it is being released under and to note that this *only* works with the MySQL version of MT.
medic119
It told me that it ran fine but it didn't touch any of my comments older than 30 days. I rebuilt the entire system like it said to and didn't get any errosr.

They all still show open in the System.

heres my pertinent mod
CODE
// $closehours is how long an entry should be open before comments should be closed on it.
// Set this to a whole number of hours OR set this to 0 and use $closedays below.
$closehours = 0;
// If you set $closehours to anything except 0 above, set $closedays to 0.
// Otherwise, set this to a whole number of days an entry should be open before comments should be closed.
$closedays = 30;
tubedogg
I have just tested this script again. After running it, editing an entry through the backend shows that entry's comments as "closed". Trying to add a comment to an affected entry shows the error "This entry is closed for comments".

One thing I just noticed is I don't think it is adhering to the time specified - it closed comments for *all* my entries, not just those older than the 7 days I selected.

Did this touch *any* comments for you?
tubedogg
OK, I believe I have squashed the date/time bug. It should now work correctly. It has been updated to v1.01 and the URL is the same as above - http://backlog.geeksblog.com/t/2003/02/23/000065
medic119
Seems to work wonderfully now!  Thanks again.
BTW, can this be run via cron or is it going to output a message causing me to get my inbox filled with cron job outputs? lol

Nice to see another e550G user as well.  Not many of us about.  Nice site!
tubedogg
e550G? Um...? biggrin.gif Not sure what that means.

It could work via cron. I have added a $nooutput switch for this type of use. Script updated to v1.1.
medic119
Genio e550G the Pocket PC you have in the header of your site... smile.gif

Thanks for the noouput switch.  Now I won't have to remember to run it every month, lol
tubedogg
Ohhhh! You would expect me to know that, since it's in my header. I don't, though. wink.gif We picked it at random - it was one of the only pictures of a PDA that we could find in a hi-rez version for the header.

Thanks for the comments about the site. smile.gif
Muffinboy
Cool, thanks tubedogg! I'm away from the screen for a day and you come to our aid smile.gif

Maybe a quick explanation why I needed the script: I'm going to restructure my site's archives from using /archives/0000012.html formatting to the date based archives /2003/12/03/entry_title.html.

I don't want to break links to my old posts, so I'm going to close their commenting and leave them where they are, with a little notice that these are the old archives.

Then I change the archiving method as described above, rebuild the archives and allow commenting only on posts created after that date. It's a bit of a pain, but I'm trying to be backwards compatible here smile.gif
crys
You could just: remove the comments code from your templates (maybe replacing it with a link to the new page) --rebuild -- restore the template -- change the archiving -- And rebuild again.

Now links to the old files don't break, nor do they not update when someone adds a comment -- without disallowing commenting on the older entries.
fooljay
(crossposted from a related thread)

If you ask me, there is nothing more annoying than comments which have been closed only due to age of the post.

I will give you an example: a long time ago, I wrote up a hack which explained how to get rid of target="_blank" in the MTCommentAuthorLink, because it ruins XHTML-strict validation. Subsequently, many people linked to it.

I realized that people were still employing this hack, even though it is obsolete for v2.6+ thanks to the sanitize attribute. So, I did a Google search on all pages linking to mine or pages which detailed the hack but did not link to mine. On all found pages, I posted the updated information. Some people retired comments by date, so I was unable to comment, leaving later Googlers with bad information.

I did the same thing recently with the (complete) fix for the MT bookmarklet for Safari.

Closing comments just because the entry is old is a bad idea. If you want to educate Googlers, you can use the MT-RefSearch plugin (http://www.sixapart.com/log/2002/12/mtrefsearch_v07.shtml) and modify the text to explain that they are on an old archive page. The plugin will provide them with relevant on-site search results and may give them an indication that there is more recent and relevant content.

Closing comments because of the occasional comment spam is throwing the baby out with the bathwater...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.