| Author |
Message |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
Different style when author posts a comment? |
|
Is there a way you could have an "Author" image or a certain effect of your choice (different cell color, larger name font, etc.) that appears when the article's author posts? I just think it creates separation from ordinary commenters is all.

|
|
| Sun Jun 22, 2008 12:38 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
Syrion

Joined: 02 Aug 2006 Posts: 172
|
|
|
| Sun Jun 22, 2008 7:16 pm |
|
 |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
|
|
Cool trick, thanks! But I'd really like an author image to pop up and maybe someone can fill me in on that.
|
|
| Mon Jun 23, 2008 5:19 am |
|
 |
Mystic2010
Joined: 10 Jan 2007 Posts: 48
|
|
|
|
Just follow the instructions and modify it a little bit. Experiment!
For example, instead of
 |  | if($tpl['comment']['author'] == "admin1"){
echo '<font style="color:red">'.$tpl['comment']['author'].'</font>'; |
you could put in
 |  | if($tpl['comment']['author'] == "admin1"){
echo $tpl['comment']['author'].'<img src="link to image here" />'; |
|
|
| Mon Jun 23, 2008 7:41 pm |
|
 |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
|
|
Okay, I'll give that a try but I have two more questions:
1. I noticed that the code was for Strawberry. Would it work in Cutenews.ru?
2. Where do I place this code? All it says on that thread is "template" but that doesn't look like the typical code you can run on your template. It has to be one of the *.inc files, but which one?
|
|
| Tue Jun 24, 2008 4:09 am |
|
 |
Mystic2010
Joined: 10 Jan 2007 Posts: 48
|
|
|
|
Hmm.. didn;t notice that, sorry. Can't help you further 
|
|
| Tue Jun 24, 2008 11:32 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2683 Location: Germany |
|
|
|
1. Add this to functions.inc.php:
 |  | if(!function_exists('commenter_is_author')){
function commenter_is_author($id, $commenter){
global $sql;
$query = reset($sql->select(array('table' => 'news', 'where' => array("id = ".$id))));
if($query['author'] == $commenter){
$return = true;
}
else{
$return = false;
}
return $return;
}
} |
2. In show.comments.php change this:
 |  | $output = str_replace('{author}', ($user_name[$row['author']] ? $user_name[$row['author']] : $row['author']), $template_comment); |
to this:
 |  | $output = str_replace('{author}', ($user_name[$row['author']] ? (commenter_is_author($id, $row['author']) ? $user_name[$row['author']].' <img src="path_to_image" />' : $user_name[$row['author']]) : (commenter_is_author($id, $row['author']) ? $row['author'].' <img src="path_to_image" />' : $row['author'])), $template_comment); |
Replace "path_to_image" with the path to the image you want to show.
(Not tested.)
|
|
| Thu Jun 26, 2008 6:19 pm |
|
 |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
|
|
Awesome! Thanks!
|
|
| Fri Jun 27, 2008 3:18 am |
|
 |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
|
|
One other thing: how do I change the text color for the username too?
|
|
| Sun Jun 29, 2008 11:09 am |
|
 |
Syrion

Joined: 02 Aug 2006 Posts: 172
|
|
|
|
I think it's better to change the <img>-tag to a span or div with a class attached and control everything from CSS.
_________________
Mini-me |
|
| Mon Jun 30, 2008 12:49 pm |
|
 |
Disharmony
Joined: 05 Jun 2008 Posts: 44
|
|
|
|
Good idea, but where do I put the <div class="namehere"></div> on that code so that the author name would be included? Putting it here (see below) wouldn't affect the color, it'll just show the image.
 |  | $output = str_replace('{author}', ($user_name[$row['author']] ? (commenter_is_author($id, $row['author']) ? $user_name[$row['author']].' <div class="namehere"></div>' : $user_name[$row['author']]) : (commenter_is_author($id, $row['author']) ? $row['author'].' <div class="namehere"></div>' : $row['author'])), $template_comment); |
|
|
| Mon Jun 30, 2008 3:38 pm |
|
 |
|