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”:http://www.7nights.com/asterisk/archive/2005/01/info-gathering#comments “blogs”:http://www.stopdesign.com/log/2004/12/16/small-screens.html#comments these days to differentiate between comments to a post.

Having done a similar task in “PHP”:http://www.php.net/ and “ASP”:http://www.asp.net/ 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”:http://www.johnsjottings.com/archives/2004/12/24/obfuscated_perl.html#comments relatively easily using Brad Choate’s wonderful “PerlScript”:http://bradchoate.com/weblog/2002/07/27/mtperlscript plugin. Here is a snippet of the code in the template:

bc(code)..
$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”:http://www.nonplus.net/software/mt/MTGrid.htm that would also accomplish this without PHP.

{ 5 comments }

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.

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

To:
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: