[support] Highlighting the blog author's comments in a blog

Earl Miles merlin at logrus.com
Sun Jan 21 17:13:36 UTC 2007


Tim Vaughan wrote:
> It's becoming more common for blogs to have their author's comments
> highlighted in the comments after a post (I was reminded of this while
> viewing Brian Jones's blog on Open XML - see
> http://blogs.msdn.com/brian_jones/archive/2007/01/19/passing-the-openxml-standard-over-to-iso.aspx#comments
> for an example).
> 
> How can I do this in Drupal?  My guess is that is requires some PHP in
> template.php plus an extra bit of css but I'm not sure of the best way
> to get this done.

You need 3 things.

In your template.php in the _phptemplate_variables() function, you need to add 
a line roughly like this:

case 'comment':
   $vars['node'] = node_load($vars['comment']->nid);

Second, in your comment.tpl.php:

<?php if ($comment->uid == $node->uid): ?>
   ...add a class to the comment...
<?php endif; ?>

And finally add a bit of CSS to act on the new class.

For more information on this, look in the handbook about phptemplate_variables. 
A lot of great things can be done with this function.



More information about the support mailing list