I’ve finally implemented author highlighting for the comments here at SimpleBits. Any comment that I add myself gets a slightly different style treatment to set it apart from the rest. I first noticed Dave doing this quite awhile back. Many others followed — and I’ve found it pretty darn useful when I read other sites, being able to quickly scan for the site owner’s remarks.
How is it done? Depending on the system you’re using, there are approximately 34,760 ways to make this happen, and I came up empty when searching for a writeup on how people handle the swap. Here’s how I tackled it.
I started by downloading the Switch plugin for MT. This allows for conditional statements within Movable Type’s templates. I’m sure there are other methods — and feel free to leave your own tips in the comments.
Once the plugin was installed, I just needed a way to insert a
class to the
<dd> elements that I use to structure the author and text for each comment. This class would only exist if the comment was authored by me.
Using the Switch plugin’s syntax I added this to the entry template:
<MTSwCase value="Dan Cederholm"> class="dan"</MTSwCase>
So here, I’m testing for when the author’s value is “Dan Cederholm”. If it is, then it’ll add whatever’s between the
<MTSwCase> tags — in this case:
class="dan". Notice the space before
class — this is important, as for every other case but “Dan Cederholm”, we’ll just have a normal
<dd>) element, without extra spaces.
With a class now inserted for my own comments, I could just add specific styles for
dd.dan to make them unique.
While I’m using the value of
MTCommentAuthor, the plugin will accept any MT tag to match against. You could use an email address, URL, etc. — or I suppose get even more fancy with IP address or other more secure methods. I do realize that, now that I’ve documented this, I’m making it easy for people to pretend to be Dan Cederholm (I’m not sure why one would want to do that), but simplicity is bliss.