magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

As this blog has attracted more and more visitors each month, the number of comments I’ve been receiving has also been on the increase. Every now and then one of my threads generates some extremely interesting feedback, and it was starting to get annoying that I couldn’t reference these comments directly. What I really wanted was the ability to link directly to a comment.

A quick look through the Movable Type documentation, and I found details for the @MTCommentID@ tag. Simply put when placed inside an @MTComments@ tag (or in my case “@MTSimpleComments@(Plugin which will print comments and trackbacks in the same listing.)”:http://mt-plugins.org/archives/entry/simplecomments.php) it will print the ID for a comment. It is then a simple matter to create an HTML anchor for that specific comment like so:

" />

In of itself this isn’t terribly useful – I need to look at the source of the page to get the anchor name, and then have to create the link by hand. So I’ve also added a comment permalink, using the following code – again within the @MTComments@ tag:

#"
title="Permalink to this comment">Permalink

So, when I next get an interesting post, I can link right to it, and so can anyone else.

_Updated_: I posted more on this subject in “Comment Permalinks revisited”:http://www.magpiebrain.com/archives/000223.html.

Advertisements

5 Responses to “Comment Permalinks with Movable Type”

  1. Cheah Chu Yeow

    What I think would be better (neater) would be to us the id of your comment div instead. There is no real need for the anchor tag anymore 🙂

    <div class=”comment”> id=”#”>

    I use SimpleComments, so I’m not sure, but the MT documentation seems to say that the MTCommentOrderNumber template tag will allow you to have your comments numbered from 1 for each entry.

    Reply
  2. Sam

    Hmm…I like the idea of using a div id – I’ll give that a go. The MTCommentOrderNumber only reflects the order however – if I change the sort order I change the numbering for a specific comment. I prefer the idea of linking to a uniquely identifiable comment as it will be more robust, even though I’m linking within the scope of a specific post.

    Reply
  3. Sam

    Thinking about it, I’m not sure that using a Div with an ID will help here – for a start the reason for using the anchor is so a link will go straight to a specific post – for example this link: http://www.magpiebrain.com/archives/000222.html#422 goes to your first comment. Secondly, isn’t this misusing what the ID tag is actually for? The anchor here is being used for navigation, not semantic markup.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

%d bloggers like this: