alternating comment styles
I've been asked how I acheive the alternating comment styles in my blog. When this blog was custom built on CodeIgniter, I used alternator() in the string helper. It looked like this:
<?php foreach ($post_comments->result() as $comment): ?>
<div class="comment<?= alternator(' even', ' odd');?>
<p><?php
if ($comment->comment_author_website) {
echo anchor ($comment->comment_author_website, $comment->comment_author_name);
} else {
echo $comment->comment_author_name;
}
?> wrote on <?= date ('F jS, Y @ G:i', $comment->comment_date);?></p>
<?= $comment->comment_body;?>
</div>
<?php endforeach; ?>
When I switched my blog over to ExpressionEngine a few months ago, I decided to change my strategy a bit, and use the tools EE makes available for me. Specificly, the {switch} tag for comments.
{exp:comment:entries sort="asc"}
<div class="{switch="even|odd"}">
<p>{url_as_author} wrote on {comment_date format="%F
%d<sup>%S</sup>, %Y @ %G:%i"}</p>
{comment}
</div>
{/exp:comment:entries}
I find it ever bit as intuitive as pure PHP, and I love the convenience shortcuts like {url_as_author} (Hyperlink pointing to the URL (if it exists) with the author name as the link title. If the URL does not exist simply the name is returned).
I still have all the legacy code (of course) from the custom written blog app, and while I don't want to release it wholesale, I'd be happy to field any specific questions about any part of it.

Pat Teglia wrote on
Ack, you mean that there is a simple one line deal, alternator, that does this!! Sonofa.
I am not even going to embarrass myself showing the code I used to do this :)