XF 1.2 Alternating Color Rows Without Any Plugin or File Uploads

Had an alternating row color for vBulletin without a plugin and wanted something similar for Xenforo. I know this is not the best way to be doing it and as Xenforo is on MVC structure may not be recommended as well but the simplicity of it made me to share it here.

In thread_view template, Find

    <xen:foreach loop="$posts" value="$post">
And replace with
    <xen:set var="$i">0</xen:set>  
    <xen:foreach loop="$posts" value="$post">
      <xen:set var="$j">{$i}</xen:set>
      <xen:set var="$i">{xen:calc '{$j}+1'}</xen:set>
      <xen:if is="{$i}%2==0">
        <xen:set var="$AltColor">Even</xen:set>
        <xen:set var="$AltColor">Odd</xen:set>
In message template find

<li id="{$messageId}" class="message
And add the class as follows

<li id="{$messageId}" class="{$AltColor} message
Finally Add the following to message.css template

.messageList .Even, .messageList .Even .primaryContent {background:@primaryLightest;}
Enjoy !!!


Well-known member
The CSS Paul has in the FAQ linked above works on posts regardless of their ID. It works on the position of the <li> element in the HTML, which is either even or odd independent of post IDs.