1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Alternating Color Rows Without Any Plugin or File Uploads

Discussion in 'Styling and Customization Questions' started by shabbirbhimani, Sep 12, 2013.

  1. shabbirbhimani

    shabbirbhimani Active Member

    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 !!!
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. shabbirbhimani

    shabbirbhimani Active Member

    No it cannot be because the post number as li id not always mean they are in right alternate order.
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    What do you mean? The post number Li should always count sequentially from 1.
  5. shabbirbhimani

    shabbirbhimani Active Member

    It adds the postid as of now and so making alternating color is not possible unless we add some counter thing.
  6. Jeremy

    Jeremy XenForo Moderator Staff 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.
  7. shabbirbhimani

    shabbirbhimani Active Member

    Ohh Yes but that is not supported in IE8 or earlier

Share This Page