Comment How-To

Recovered from the Wayback Machine.

In comments to my last posting Jonathon, asked the following about my new comment modification:

Is that standard in (later versions of) MT? Or a custom-coded Burningbird special?

Answer: a bit of both.

The code is based on templates and an example that Ben and Mena provided, but I customized. So I thought I would provide a how-to if others are interested in incorporating at their weblogs.

First, I added permalinks for my comments, so that clicking on the specific comment takes the person directly to the comment. I changed the MT template code for comments within the individual entry archive template to the following (modifications are in bold text):

<a name=”comment<$MTCommentID>”></a>
<span class=”comments-post”>Posted by:
<$MTCommentAuthorLink spam_protect=”1″$> on
<a href=”<$MTEntryLink$>#comment<$MTCommentID$>”>

Once permalinks have been added, I then added the comment code to the main template page. This is a modification of example code the Trotts have provided:

Update: Code has been altered to remove hard coded URL per note from Sam Kington — thanks Sam!

<MTComments lastn=”10″ sort_order=”descend”>
<a href=”<$MTBlogArchiveURL$>/<$MTCommentEntryID pad=”1″$>.htm#comment<$MTCommentID$>”>
<$MTCommentAuthor$></a> on <MTCommentEntry>
</MTCommentEntry><br />

From top to bottom: The outer comment block is necessary for using the comment tags. In addition, it also provides instruction to list the last ten comments. The next line then forms the link, which is based on the static archive location appended with the entry id and the comment entry id, both based on MT tags. The next lines add the comment author and title, again both from MT tags.

I’m using MT 2.51, but this should work with any version of MT that supports all of the tags I’ve outlined.

Holler if you have any questions.

Update (12/29/02)

Jonathon Delacour, Mr. Markup to us angle-bracket challenged, pointed out that the name anchor reference is deprecated for XHTML. Instead, the preference is to use id. When I update the weblog to XHTML, I’ll be using the id attribute instead, which is gonna bust heck out of any remaining old browser here abouts.

Anyway the change would be to pull the anchor tag (the <a name=…>) and replace with:


<div class=”comments-body” id=”comment<$MTCommentID>”>


Thanks to Jonathon for heads up and correction.

Print Friendly, PDF & Email