Alternating row colors in a Post Island

UBB.threads usually allows for alternating row colors in many of the parts of the forum and it is nice to have in order to set apart the rows by color (or more specifically CSS styling).

The Post Island is such a creature that doesn’t allow this for some reason. Oversight? I really don’t know, but it is really a small tweak to put in the option to alternate the rows and make them have a distinct look.

There is only one file to edit and it isn’t code, so you aren’t going to really break anything here if at first you goof it up or fat finger something.

Open templates/default/post_island.tpl


{section name=item loop=$items}
<td class="{$style_side}alt-1" align="left">

and replace it with:

{section name=item loop=$items}
{if $smarty.section.item.iteration is odd}
<td class="{$style_side}alt-1" align="left">
<td class="{$style_side}alt-2" align="left">

Save changes and upload and voila.

Now it will alternate between the .(right/left)alt-(1/2) styles as it does a new row.

For those who don’t want alternating row colors, you have two options:

  • Simply don’t make the change that I’m suggesting here and leave the template as is
  • Make your rightalt-1, rightalt-2 and leftalt-1, leftalt-2 styles the same

I suggest at least doing the template change, because it gives you all the flexibility you may want down the road and then you can use CSS to accomplish whatever you want, based upon the board style you might be working with at any particular moment.

This was short and sweet, because there isn’t a whole lot of complexity in the matter.

Enjoy it for what it’s worth.

That’s it.

Comments are closed.