Movable Type User Manual: COMMENTS

« Table of Contents


COMMENTS

Movable Type features a built-in comment system. You can edit existing comments for a particular entry by selecting that entry for editing, then looking in the Edit Comments area. Comments will be listed there; you can edit a comment by clicking on the name of the author, then editing the comment on the resulting page. You can delete comments by checking their checkboxes, then clicking DELETE CHECKED.

The default templates that ship with Movable Type are comment-ready; in other words, you should be able to use comments in your weblog without editing any of the comment templates at all. The default templates are set up so that comments appear on both the popup comment window (linked from the Main Index template) and the individual archive pages. You can alter this behavior by altering the appropriate templates.

Movable Type's comment system can be used in either of two ways (or both):

Of course, in either of these scenarios, you will also want to provide a form for users to enter new comments. That form can look something like this:

<form method="post" action="<$MTCGIPath$><$MTCommentScript$>">
<input type="hidden" name="entry_id" value="<$MTEntryID$>">
Name: <input name="author"><p>
Email Address: <input name="email"><p>
URL: <input name="url"><p>
Body: <textarea name="text" rows="10" cols="50"></textarea><p>
<input type="submit" name="preview" value="PREVIEW">
<input type="submit" name="post" value="POST">
</form>

If you are using static/inline comments, note that the sample form above will require the addition of one more hidden input field:

<input type="hidden" name="static" value="1">

This tells the comments system that you are using inline comments, which will force a rebuild of the entry archives and of the index pages for your weblog, after a new comment is posted.

Note that in either scenario--inline comments or popup comments--your index pages will be rebuilt after a new comment is added; this is to update the count of the number of comments on the entry (see the MTEntryCommentCount tag, in TEMPLATE TAGS). In addition, if you are using inline comments, your archive pages for the entry will be rebuilt; this is to add the new comment to your individual entry archive page for the entry.

Comment Previewing

Comment previews are built into Movable Type, so that your visitors can preview their comments before posting. Support for previews ships with the default templates built into the system; you can remove this support, if you wish, by removing the PREVIEW button from the comments form. The layout of the comment previews is defined using the Comment Preview template. You can use the <$MTCommentPreview*$> tags, along with the global tag attribute encode_html, to create an editable comment preview form; this allows users to preview their comment, then edit the comment being previewed, then post the comment. The default templates have an example of an editable comment preview template.

When creating an editable comment preview template, you should always paste this hidden input field into the forms in your Comment Preview and Comment Error templates:

<input type="hidden" name="static" value="<$MTCommentPreviewIsStatic$>">

This is a magical tag that tells the system whether a user is posting a comment from your individual archives, or from the comment popup window, so that the user can be redirected to the proper page after posting a comment.

You can also list all of the previous comments posted to the entry, using the standard <MTComments> container tag:

Previous comments:
<MTComments>
<$MTCommentBody$>
Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$>
</MTComments>

Comment Submission Errors

If an error occurs when a comment is submitted--for example, if you have disallowed anonymous comments, and the user does not supply a name or email address--you can customize the error page that the user receives using the Comment Error Template. You can use this template to provide a form where users can fix whatever error has occurred in their submissions, then re-post (or preview) the comment. The default templates have an example of a Comment Error Template ( http://www.movabletype.org/default_templates.shtml ).


Copyright © 2001, 2002 Ben Trott and Mena Trott. All Rights Reserved.