MovableType Bug Fix

I’ve been using MovableType for over a year now. I’ve learned it capabilities and limitations and all around I really like it. It’s flexible, allows you a lot of template control, and if you like to get your hands dirty, it’s a good primer for the nuts and bolts of setting up a database driven website. Mmm, mmm, good.

One thing that always bothered me was the default code for the comments. It’s a giant nested if… then structure with javascript thrown in. Impossible to read through the template editor on the web. On top of the complexity, I knew there was a bug in there. If you sign in through TypeKey, which seemingly no one but me does, it never acknowledged it. I saw a sentence in the template that read, “Thanks for signing in,” but it never appeared on the finished page. So finally I sat down and made my way through it.

I noticed the “Thank you” appeared if you previewed your comment before submitting it. So I compared the code from the comment previewing template and the individual post template. I narrowed it down to the two <script> tags with that were supposed to output the thank you string.

A ha! The comment preview read if(getCookie(“commenter_name”)) whereas the post template read simply commenter_name. I quickly wrapped the variablein the function wherever it occurred and updated my site. I signed into TypeKey and after I was redirected to the post it thanked me for signing in! Great success!

Here’s teh code if you have the same problem. Any site using an MT 3.15 or older installation is probably affected actually.


if (getCookie("commenter_name")) {
document.write('<p>Thanks for signing in, ', getCookie("commenter_name"), '. Now you can comment. (<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=handle_sign_in&static=1&entry_id=<$MTEntryID$>&logout=1">sign out</a>)</p>');
} else {
document.write('<p>If you have a TypeKey identity, you can <a href="<$MTSignOnURL$>&<MTIfNeedEmail>need_email=1&</MTIfNeedEmail>
t=<MTTypeKeyToken>&v=1.1&_return=<$MTCGIPath$><MTCommentScript>
%3f__mode=handle_sign_in%26static=1%26entry_id=<$MTEntryID$>”> sign in</a> to use it here.</p>’);
}
// –>