Alternate Comment Rows

From Habari Project

Revision as of 01:48, 18 October 2009 by drzax (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can configure your theme to 'style' comment rows differently. By using CSS, this can be used to make comment lists visually easier to differentiate. We can also set a custom CSS class whenever the owner responds.

Here is a sample of this being accomplished:
<?php if( $post->comments->moderated->count ) : 
$class = '';
?>
 
	<h3 id="comments"><?php echo $post->comments->moderated->count; ?> Responses to &#8220;<?php echo $post->title; ?>&#8221;</h3>
	<ol class="commentlist">
<?php foreach ( $post->comments->moderated as $comment ) :
                // The alternate row change
                $class = (($class == '') ? 'alt' : '');	
                 //check to see if post author email is same as comment author email  
		if( $comment->email == $post->author->email ) {
			$class= 'owner';
			}
		if ( $comment->status == Comment::STATUS_UNAPPROVED ) {
			$class= 'unapproved';
			}
?>
<li id="comment-<?php echo $comment->id; ?>" class="<?php echo $class; ?>">
   <span class="commentauthor"><a href="<?php echo $comment->url; ?>" rel="external"><?php echo $comment->name; ?></a></span>
   <small class="commentmetadata"><a href="#comment-<?php echo $comment->id; ?>" title="Time of this comment">
   <?php echo $comment->date; ?></a> <?php if ( $comment->status == Comment::STATUS_UNAPPROVED ) { ?>
   <em>Your comment is awaiting moderation.</em><?php } ?></small>
 
   <?php echo $comment->content_out; ?>
 
</li>
<?php endforeach; ?>
</ol>
 
<?php endif; ?>
Personal tools