A common issue I see come up with MT users customizing their templates
is getting the comment form to work properly when registration is required
or an option. Unfortunately authentication (logging in) and dynamic display
is relatively more involved then simply laying out content in pages.
Here are some of the common mistakes I've seen users make:
Forgetting to load the blog's JavaScript library.
Be sure you are including (loading) the blog's MT javascript files in
the page head of all your entry and page templates that have a comment
form. By default this file is mt.js and is
generated by an Index Template called JavaScript in MT4.
<script type="text/javascript" src="<$mt:link template="javascript"$>"></script>
Modified or missing tag IDs.
Be sure to keep the same HTML/CSS ids. The JavaScript library MT
generated for each blog powers the display of the comment form and
remembering a users info. I'm not going to list them all here because there
are quite a few. The default comment form markup can be found in the file
named comment_form.mtml in the mt4/default_templates directory.
Missing hidden form variables.
MT comment forms need to pieces of information passed as hidden field
variables:
<input type="hidden" name="static" value="1" />
<input type="hidden" name="entry_id" value="<$mt:entryid$>"/>
<input type="hidden" name="__lang" value="<$mt:bloglanguage$>" />
The static field tell the MT comments script it is receiving its content
from a static page rather then a dynamic script. (This is mostly a legacy
issue from previous versions of MT.) The other is the system ID for the
entry or page the comment is to be associated. The __lang (yeah that double
underscore prefix is kind of ugly and seemingly unnecessary) is new to MT4
templates and (remarkably) define what language to use with its system
messages. It's not clear to me why MT can't look this up rather then having
us pass it. For now, just do it.
Forgetting to run individualArchivesOnLoad once the
page has loaded.
Be sure your entry and page templates are running
individualArchivesOnLoad(commenter_name) once the body is
loaded. The MT default template will generate something like this:
<body onload="individualArchivesOnLoad(commenter_name)">
I structure my custom templates differently and prefer to handle this
differently by placing this piece of scripting in my page head:
<script type="text/javascript">
// <![CDATA[
window.onload = function() {
individualArchivesOnLoad(commenter_name);
}
// ]]>
</script>
It's a bit more involved, but I have the option of adding other routines
to run after loadings and I avoid the conditional logic to generate the
body tag like the MT4 default template.
Make sure you don't run individualArchivesOnLoad too soon.
If your comment form elements haven't loaded before the browser runs this
function you will see a JavaScript error like "document.body had no
properties."
Modified form button names.
MT uses the names of the Post, Previews and (now in MT4) Reply buttons
to know what mode to process the comment being submitted. Some users will
understandably want to rename these buttons and will change the value (the
label) AND the name. You need to keep those name or make
addition arrangements to submit this information with each comment using
another hidden variable or a javascript.
Final word
I hope this will be helpful to those who are under taking such a task.
This is not a complete list. A related area of problems is in getting your
authentication setup and running properly. MT4 introduced a lot of changes
in this area -- a subject worthy of a separate post entirely.
Customizing your templates and getting them to work with the
registration capabilities MT supports is doable -- its just requires a bit
of extra patience and know-how.