Last week, we snuck in another nifty new feature, but we've been making some adjustments and tweaks prior to publicly announcing it today. It's the ability to style comments uniquely on blog posts if those comments are left by the post's author or, alternately, by any logged-in user on your site.
Two separate classes will be added to the markup of the comments. One class is added to comments created by any logged-in user. The other class is added to comments created by the post's actual author. Since "authors" are a subset of "users," both classes will actually be added to the author comments, giving you ultimate flexibility.
Our system defines the actual author as the user who first created and saved the post. If a different user updates the post later, that won't change the actual author.
Why the two style options?
We wanted to make sure you had flexibility. We can envision cases where you would want to style only the author's comments uniquely and also cases when you might want to style any logged-in user's comments. For example, here on our LightCMS blog, there are several members of our team who contribute to the blog, and we'd like to identify all of their comments uniquely. So we are styling all users' comments and then adding a special bit of styling to the actual author to set him or her apart. However, if you have a website with lots of users, you may not want all of those users' comments styled, so in such a case, you can just use the author comment hooks.
How it works
The author or user must be logged into the system when leaving the comment for it to be recognized correctly. Comments left by any logged-in user will have a class of "userComment" added to the <dt> and <dd> tags surrounding the title and body portions of the comment. Comments left by the actual author will have both the "userComment" class and an additional “authorComment” added to the same tags. A sample of the markup generated by an author comment is included below.
<dt class="comment userComment authorComment" id="comment90451">
<a href="#comment90451" title="Link to this comment" class="commentNumber">1.</a>
<a title="" href="" rel="nofollow">Name of commenter</a> wrote:
<dd class="comment userComment authorComment">This is the content of the comment.
<p class="commentDate">August 26, 2010 @ 10:23 AM</p>
Please note: this new functionality will only apply to comments left after the point of release of the update, which was approximately 10:30am CDT (GMT -5) on Thursday, August 26th, 2010. Prior to this release, we were not tracking the user information associated with comments, and so the classes will not be applied to comments left before that point.
See an example
We're going to leave some sample comments on this post below so that you can see how it works with the styles we've created for the LightCMS blog. Of course, you can style your comments however you wish. Ours is just an example. So, check it out, and leave us a comment while you're at it!
Thu, September 2, 2010
by Tim Wall filed under