Comments by specific user a different style (e.g. background color)

Acert93 - March 28, 2007 - 05:48

I am curioius if Drupal will allow me to setup a style that will make a specific users comments different.

Right now in the theme I am using comments that need approval from unregistered users have a pink background and approved comments are white. How would I go about making the comments from the user "me" have a different style, like a blue background?

Simiarly, is there a way to en masse style all registered users styled one way and unregistered another.

Thanks :D

Do it in your comment.tpl.php file

duggoff@drupal.org - March 28, 2007 - 16:46

There is a file included in most themes that is used to style comments. You could probable add an if..then statement to surrount the <?php print $contents ?> statement with some custom CSS if the user's uid=whoever. Something like this:

<div class="content"><?php if ($node->uid == whoever){print '<div class="your_class">'?><?php print $content; ?><?php print '</div>'; }; ?></div>

Something like that. I wouldn't cut and paste that code :-) I'm still working on my first coffee of the morning. The problem is, you would have to check every uid, and that could get pretty time consuming. You'd be somewhat better off if you created a role to for all the people who you wanted to do this for, then test for that role id...I think. Anyway, it's possible, and the code above should start to point you in the right direction.

Doug Gough

This works for me…

syquest - June 12, 2007 - 09:38

Before each class I wish to custom style for the administrator, I place the following:

<?php if ($comment->uid == 1): ?><div class="admin_comment"><?php endif;?>

<?php if ($comment->uid != 1): ?><div class="general_comment"><?php endif; ?>

Then in my CSS file:

. admin_comment {
background-color: blue;
}

. general_comment {
background-color: green;
}

 
 

Drupal is a registered trademark of Dries Buytaert.