Alternating comment colouring in MT without PHP

Using my “Switch plugin”:http://virtuelvis.com/archives/2003/03/mtswitch you can create alternating background colors for comments. The technique is quite simple.


First, set this somewhere near the top of your index template (before any comments):
bc.
Then, modify the MTComments section of your individual entry archive, so that the value is alternated.
bc.







“>

<$MTCommentAuthor$> said:

<$MTCommentBody$>


Please note that the MTSwitch tags do not strip whitespace, so you might want to remove any superfluous newlines and spaces inside this tag.
Finally, you can go on to modify your CSS, so that every odd and even comment gets alternating colour:
bc. div.oddcomment { background: #ccc; }
div.evencomment { background: #fff; }
Enjoy!

Previous Post

1 Comment

  1. Shannon

     /  2005-10-31

    Hey,
    Thanks so much – this was fast, easy and works really well. I’m not a programmer, and was able to implement alternating backgrounds on my comments with ease.
    One question: Can I set a third variable with a different background? I’d like to have alternating comments, but a separate background for myself when I decide to add a comment of my own.
    Thanks again. 😀
    Shannon