« Tag Cloud on PHP in Movable Type 4 | Main | Install Movable Type Under Windows (IIS) »

Upgrading to Movable Type 4 with MTCommentFields

By now, there's a reasonable chance that if you've wanted to upgrade to the latest release of Movable Type, you've done so. But you may still be waiting. Perhaps you're hoping that your favorite plugin will be updated (there are still a few that haven't been released for MT4). Or maybe you've run into a problem that you can't seem to overcome.

One of the issues that I run into fairly regularly is for people who use the MTCommentFields tag. This tag, originally released in version 3.0D - way back in 2004, for those of you keeping track - was designed so that you wouldn't have to keep up with your comment form. Unfortunately, people like to keep up with their comment form, to move it around, change some wording, add features or just tinker. So it rapidly fell out of favor, and in MT4, it's gone completely.

If you're still using it and you want to upgrade, you'll see a message that reads The MTCommentFields tag is no longer available; please include the Comment Form template module instead. You will be able to rebuild your templates, but you won't be able to accept any new ones.

And naturally, if you're upgrading, you won't have this module to make that happen. To make matters worse, if you're a user of certain versions, even if you try and get rid of the tag, you might still have problems. What do you do? Luckily, it's an easy fix.

To fix this problem, you need to first make two changes to your Individual Entry Archive template. Users who first created this template in a version of Movable Type from v3.0D to 3.17 will have to make three changes. Ready? Here we go.

First, click on Design, then Archive Templates. You are looking for the Individual Entry Archive template. Near the top, locate the JavaScript in the template. It will look something like this:

<script type="text/javascript" language="javascript">
var HOST = \'<$MTBlogHost$>\';
// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.
function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
function getCookie (name) {
    var prefix = name + \'=\';
    var c = document.cookie;
    var nullstring = \'\';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
function rememberMe (f) {
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    if (f.author != undefined)
       setCookie(\'mtcmtauth\', f.author.value, now, \'/\', HOST, \'\');
    if (f.email != undefined)
       setCookie(\'mtcmtmail\', f.email.value, now, \'/\', HOST, \'\');
    if (f.url != undefined)
       setCookie(\'mtcmthome\', f.url.value, now, \'/\', HOST, \'\');
function forgetMe (f) {
    deleteCookie(\'mtcmtmail\', \'\', HOST);
    deleteCookie(\'mtcmthome\', \'\', HOST);
    deleteCookie(\'mtcmtauth\', \'\', HOST);
    f.email.value = \'\';
    f.author.value = \'\';
    f.url.value = \'\';

You want to remove this entire block and change it to this:

<script type="text/javascript" src="<$MTLink template="javascript"$>"></script>

Various versions of the software would create a Site JavaScript file for you. If you view your template listing (index templates) and see a file with a name of Site JavaScript, you'll enter site javascript here. If you see a file with a name of JavaScript, enter javascript here. Case is not important.

This allows Movable Type to pull the name of another template - in this case the JavaScript (or Site JavaScript) - and fill in the blank. This is a much better solution than hardcoding the name, because people have a tendency to tinker with names, and what though a lot of people don't change the name, some might, so this covers most bases. If you change the name, just make sure you change this value.

If for any reason you don't have the JavaScript (or Site JavaScript) template, you can find a new one by looking in the default_templates directory if your Movable Type distribution. In fact, this isn't a bad idea, as new content is periodically added to this file, so you may gain some new functionality by updating this file from time to time as new versions are released.

Next, you need to scroll down and locate the MTCommentFields tag. By default, it is located slightly down the screen, between two tags for MTIfCommentsAllowed:


You can simply delete it - but if you do, you need to replace it with something (unless you don't plan on accepting comments, in which case you can save it and you're done).

If you do want to accept comments, then the simplest change is to alter the tag by changing all three lines to an MTInclude statement, which includes the aforementioned Comment Form. Don't worry about the form itself that you need to include right now - we'll create that in a moment. Here is what it should look like:

<$MTInclude module="Comment Form"$>

Remember, replace all three lines with this one. It won't really hurt to leave the outer MTIfCommentsAllowed statements there, but you don't need them, and you're just making more work for the template, because the Comment Form template handles that for you.

Before you save the template, however, you may have one more change to make. So scroll down to the bottom and look for these lines:

<script type="text/javascript" language="javascript">
if (document.comments_form.email != undefined)
    document.comments_form.email.value = getCookie("mtcmtmail");
if (document.comments_form.author != undefined)
    document.comments_form.author.value = getCookie("mtcmtauth");
if (document.comments_form.url != undefined)
    document.comments_form.url.value = getCookie("mtcmthome");
if (getCookie("mtcmtauth") || getCookie("mtcmthome")) {
    document.comments_form.bakecookie[0].checked = true;
} else {
    document.comments_form.bakecookie[1].checked = true;

Present in the default template from version%

Comments (4)


Hi, my individual archive template seems to be working fine (though it's not all modular like the fancy new default templates), but my "Comment Preview" template has stopped working because MTCommentFields is no longer supported. With MTCommentFields, it was really easy, because there was a parameter for preview that meant that people who previewed would get a form that had what they entered prepopulated.

However, when I switch over to creating a comment form module as laid out in your entry above, I get a form that doesn't prepopulate data and also has all these weird __trans phrase="" type tags, like this:

My assumption here is that MT is supposed to interpret this and output something, but what it's really just doing is literally typing out the __trans phrase="Name" text, which is obviously wrong. Any idea what the deal is with this? I guess I can just overwrite it with whatever text I want to show up there, but the __trans phrase syntax baffles me. It's got to be there for a reason right? Also, overwriting it won't do anything to prepopulate the data.


Looking a little closer at some of these things, I think I've figured out the issues. I still have no idea what the deal was with the whole __trans stuff, but when I looked at a newly created blog's templates, I noticed that the __trans stuff wasn't there, so I just copied the Comment Form module to my blog. Then, looking at the Comment Form module a little closer, I noticed that there was a MTIf statement that was testing if the "comment_preview_template" was present, and if it was, prepopulate the fields. So you need to make sure your comment preview template has an variable like this:

Seems to be working now.


You're missing a closing 'script' tag on the second (one-line) block of code.

@anon - Thanks for the note. It was actually there, but I missed changing it to an entity, so you would have to have viewed the source to see it. All fixed up now!