When executed this tag will change all open comments to closed comments on posts that are too old. This is controlled by an attribute on the tag or by the number of days for the main index.
MTCloseComments executes an SQL query that closes comments for posts for entries that were created more than a certain number of days ago and have open comments. This should be sufficiently fast that it can be done every time the main index template is executed.
The attributes recognized by MTCloseComments are
oldattribute is set to a numeric value then comments are closed for posts more than that many days old. If the attribute is not present then the tag looks up number of days for posts on the main index from the weblog configuration and posts older than that have their comments closed.
The tag only closes comments for posts for which comments are open. Posts for which comments are disallowed are not closed.
While this tag normally generates no output, if you set the attribute
debug to a value
then it will generate text in all cases with either details on its actions or failures.
Close comments for posts more than 21 days old.
Close comments for posts that are too old to appear on the main index.
Close comments for posts that are not on the front page and have been inactive for at least three days.
<MTCloseComments old="7" inactive="3">
Close comments for posts at least 7 days old and inactive for three or more days.
MTCloseComments works with Movable Type version 2.6 or later.
(mt home)/plugins/MTCloseComments.plThe best way to activate MTCloseComments on your weblog is to edit your main index template and put the
MTCloseCommentstag somewhere in the template. The actual location is irrelevant since the tag doesn't generate output. For efficiency reasons the tag should not be placed inside any container tags so that it is executed only once while building the main index. (Optional) In the standard MT distribute, the modified value of a post is changed only by directly editing the post. To make posting a comment update the post modification time (which is used by
inactive) you must add a line to
MT/lib/App/Comments.pmaround line 106.
$comment->url(remove_html($url)); $comment->text($q->param('text')); $comment->save; $entry->save; # <-- ADD THIS LINE $app->rebuild_indexes( Blog => $blog )
MTCloseCommentstag in your main index you need to set the
inactiveattribute to at least one in order to be able to open comments on old posts. Without that then the comments on the post will be closed by the rebuilding process during the save after the comment state is modified. There are some issues with weblogs that do not always serve comments dynamically in relation to the use of the
MTEntryIfCommentsOpentag. MTCloseComments does not rebuild any pages and so static pages using this tag will not be updated to remove the ``Post a comment'' form. However, if a user attempts to post a comment they will not be able to do so, they will just be annoyingly mislead on viewing the post. A full rebuild will clear up any such posts.
It would be very difficult
to fix this problem with this design because it would create dependency cycles where
the rebuild of a post would trigger the rebuild of the main index which (via
would trigger the rebuild of the post again.
To file bug reports or feature requests (other than topics listed in the Caveats section above) please send email to:
You should add the
debug attribute to the tag and retrieve the output, or the error
message you get from MT when rebuilding.
intin to the debug clause because the conversion result is only used in that case.
Alan M. Carroll http://thought-mesh.net
Copyright (c) 2003 Alan M. Carroll (http://thought-mesh.net/) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name ``MTCloseComments'' nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided by the copyright holders and contributors ``as is'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.