Alternating Rows in PunBB

After freshening up the Mint Forum I received a number of emails asking how I hacked the excellent PunBB to display alternating rows. So to save anyone else the trouble of emailing here’s the simple three line edit to the forum and topic lists, index.php and viewforum.php respectively. (These line numbers are from PunBB 1.2.11 but the logic in the modified areas shouldn’t change too much from version to version.)

Open up index.php and insert the following before the while loop on line 46:

$alt = true;

Then, on the line after the opening { of that same while loop add:

$alt = !$alt;

Finally, around line 126 (above the closing ?>) add:

if ($alt)
{
    $item_status .= ' alt';
}

In viewforum.php the while loop begins around line 141 and the closing ?> around line 207.

With these changes in place, style the alternate rows using the following selectors:

.blocktable tr.alt td {}
.blocktable tr.inew.alt > td {}
.blocktable tr.isticky.alt > td {}

Without going into too much detail, the > child selector is used to “hide” the more specific, multi-class alternate styles from older versions of IE PC (less than 7.0). The older IEs only “see” the last class of a multi-class single element selector. Without the child selector, the above example would result in all alternate rows looking like alternate sticky rows.

Previous
StyleGala going for $30k
Next
Clearance
Author
Shaun Inman
Posted
May 19th, 2006 at 11:17 am
Categories
CSS
PHP
Mint
Web
Comments
002 (Now closed)

002 Comments

001

Thanks…

Author
Steven
Posted
May 19th, 2006 8:58 am
002

Thanks, this is good too know.

Author
Mat
Posted
May 19th, 2006 11:01 am