Alternating Comment Colors Without PHP

by john on January 4, 2005

In my redesign I wanted to incorporate the alternate color blocks used by “many”: “blogs”: these days to differentiate between comments to a post.

Having done a similar task in “PHP”: and “ASP”: I knew the simple trick to making it work but what I wasn’t sure about was how to incorporate it into my Movable Type templates where I am not using PH I have it installed and I could use it, but I wanted to handle this without it.

I was “able to accomplish it”: relatively easily using Brad Choate’s wonderful “PerlScript”: plugin. Here is a snippet of the code in the template:

$val = <$MTCommentOrderNumber$> % 2;
print qq(

modular arithmetic.

p(update). [UPDATE] – After I wrote this article I found a link (thanks to my inline Google articles) to a very robust plugin called “MTGrid”: that would also accomplish this without PHP.


tom sherman January 16, 2005 at 6:47 pm

You may have a typo in the above code. I believe you’re missing a dollar sign for the MTCommentID tag.

print qq(<div class=”com$val” id=”comment<$MTCommentID>”>)

print qq(<div class=”com$val” id=”comment<$MTCommentID$>”>)

john January 16, 2005 at 8:32 pm

Fixed, thanks Tom.

tom sherman January 20, 2005 at 11:28 pm

I implemented this on my own site. Thanks, John!

timsamoff April 9, 2005 at 5:58 pm

Hi, John…

I came across your script when looking for a way to acheive this on dynamic pages in MT3.15… I’m wondering if you have tried this and succedded. I installed it and I am getting this error on my dynamic archives:

The requested page could not be found.
Smarty error: [in mt:360 line 53]: syntax error: unrecognized tag ‘MTPerlScript’ (Smarty_Compiler.class.php, line 556)

(Which is a common “can’t do this on a dynamic page” error.)

DamionKutaeff March 22, 2008 at 2:03 pm

Hello everybody, my name is Damion, and I’m glad to join your conmunity,
and wish to assit as far as possible.

Previous post:

Next post: