Integrating MT-Approval: Comments

It is very important that you get the configuration right for MT-Approval because if you don't, you may not be able to receive any comments. While this will alleviate your comment spam problem, you will completely destroy your good comments as well!

In recent versions of Movable Type you now have a Comment Form template that is used for both the individual archive and comment previews, which means that you only have to make changes in a single place. If you don't use the default templates, either because you use your own or didn't upgrade for some reason, then you might need to make the change in more than one place.

First, we'll take a look at changing the Comment Form template, and then we'll look at what to do if you don't have this template.

The Comment Form template can be found in the Template Modules section. Open it up and scroll down to this line:

<form method="post" action="<$MTCGIPath$><MTCommentScript$>" name="comments_form" id="comments-form" onsubmit="if (this.bakecookie.checked) rememberMe(this);">

If you use the syntax highlighting, you'll find it on line 15 of the module. At this point, you have several options. The simplest change is to replace this line with a single template tag:

<$MTApprovalCommentForm$>

When you do, all the necessary fields will be added for you to the form. Simply save the module and re-publish your site. If you'd like a little more control over what is happening, or just want to know what's going on behind-the-scenes, read on.

This template tag actually replaces the form declaration, as well as adds a couple of hidden fields and includes some JavaScript. What you'll end up with afterwards looks like this:

<form method="post" action="$msg" name="comments_form" id="comments-form" onsubmit="if (this.bakecookie.checked) rememberMe(this); setDate('$save_date')">
<input type="hidden" name="$load_date" id="$load_date" value="" />
<input type="hidden" name="$save_date" id="$save_date" value="" />
<input type="hidden" name="$beacon" id="$beacon" value="$entry_id" />
<script type="text/javascript" src="$jsp"></script>
<script type="text/javascript">
setDate('$load_date');
</script>

Everywhere that you see a value in bold (such as $msg), the value will be replaced when the template module is built. That allows the plugin to fill these in when it runs with the values you specify in the configuration. After this is done, all you need to do to change any of those values is update the settings, re-publish, and you're good to go - it's as simple as that.

But if for any reason you'd like to enter this data yourself, you can certainly do that. Each of the variables is available through a template tag, so you can place them wherever you like. Your form might instead look like this:

<form method="post" action="<$MTBlogURL$><$MTApprovalMSGTemplate$>" name="comments_form" id="comments-form" onsubmit="if (this.bakecookie.checked) rememberMe(this); setDate('<$MTApprovalSaveDate$>')">
<input type="hidden" name="<$MTApprovalLoadDate$>" id="<$MTApprovalLoadDate$>" value="" />
<input type="hidden" name="<$MTApprovalSaveDate$>" id="<$MTApprovalSaveDate$>" value="" />
<input type="hidden" name="<$MTApprovalBeaconName$>" id="<$MTApprovalBeaconName$>" value="<$MTEntryID$>" />
<script type="text/javascript" src="<$MTApprovalJSPTemplate$>"></script>
<script type="text/javascript">
setDate('<$MTApprovalLoadDate$>');
</script>

You'll notice that the template looks just the same - the only difference is that the Perl-style variables have been replaced by Movable Type template tags. So now you can structure your form any way you like. Just make sure that you get the right pieces in there - you'll need to have them all or it's very possible that it won't work!

- The form action should be the Message Template (not the words Message Template, but the location of the Message Template). The reason for this is so that automated processors that don't support JavaScript won't be able to post. Any client that supports JavaScript will automatically have the action updated correctly to point to the right place.

- The onsubmit needs to have an additional item that sets the save_date (which can be an alternate name if you've set one) appropriately. If you don't, then not only will this value not be set, but the threshold won't be set either - a double whammy!

- The two hidden fields are set with the variable so that they can correctly load the name of the fields from your configuration. The reason this is so important is that if everyone used the same name, it would be much less effective.

- The JavaScript here serves two purposes - the first call sets the form action and the second part sets the load_date when the page is initially loaded. So you want to make sure you have both - though they don't have to be right here, it's easier to have them all together so you don't miss anything.

Return to the MT-Approval configuration options.

Recent Entries

MT-Notifier 6.0.0
Change license to Artistic You read that right. Effective immediately, MT-Notifier has returned to its roots, and there is…
MT-Notifier 5.0.1
Add newline to mt-notifier-queue.cgi Update Plugin.pm with comment and entry checking code Update template capitalization…
MT-Notifier 5.0.0
Added ability to store templates in database Added template tag context to allow use of MT tags Changed code…