Alternating Comment Colors Without PHP

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.

Similar Posts:

5 Responses to “Alternating Comment Colors Without PHP”

  1. 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$>”>)

  2. Fixed, thanks Tom.

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

  4. 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.)

  5. DamionKutaeff on March 22nd, 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.

Leave a Reply