Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Different style when author posts a comment?

 
Reply to topic    Forum Index » Suggestions View previous topic
View next topic
Different style when author posts a comment?
Author Message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Different style when author posts a comment? Reply with quote
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 View user's profile Send private message
Guest








Please login to hide the ads.

Syrion



Joined: 02 Aug 2006
Posts: 172

Post Reply with quote
Not sure if it works for cutenews.ru, but try this: http://forums.cutenewsru.com/viewtopic.php?t=671

_________________
Mini-me
Sun Jun 22, 2008 7:16 pm View user's profile Send private message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Reply with quote
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 View user's profile Send private message
Mystic2010



Joined: 10 Jan 2007
Posts: 48

Post Reply with quote
Just follow the instructions and modify it a little bit. Experiment!
For example, instead of
Code:
if($tpl['comment']['author'] == "admin1"){

  echo '<font style="color:red">'.$tpl['comment']['author'].'</font>';

you could put in
Code:
if($tpl['comment']['author'] == "admin1"){

  echo $tpl['comment']['author'].'<img src="link to image here" />';

Mon Jun 23, 2008 7:41 pm View user's profile Send private message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Reply with quote
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 View user's profile Send private message
Mystic2010



Joined: 10 Jan 2007
Posts: 48

Post Reply with quote
Hmm.. didn;t notice that, sorry. Can't help you further Sad
Tue Jun 24, 2008 11:32 am View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2683
Location: Germany

Post Reply with quote
1. Add this to functions.inc.php:
Code:
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:
Code:
$output = str_replace('{author}', ($user_name[$row['author']] ? $user_name[$row['author']] : $row['author']), $template_comment);


to this:
Code:
$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 View user's profile Send private message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Reply with quote
Awesome! Thanks!
Fri Jun 27, 2008 3:18 am View user's profile Send private message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Reply with quote
One other thing: how do I change the text color for the username too?
Sun Jun 29, 2008 11:09 am View user's profile Send private message
Syrion



Joined: 02 Aug 2006
Posts: 172

Post Reply with quote
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 View user's profile Send private message
Disharmony



Joined: 05 Jun 2008
Posts: 44

Post Reply with quote
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.

Quote:
$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 View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Suggestions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.