Dragonfly CMS v9 ⇒ CPG-BB (forum) ⇒ Alternating Post Colors ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks CPG-BB (forum)

Alternating Post Colors Reply to topic


I noticed since switching back to the current forums, our posts were being displayed in alternating colors. Row1 then Row2, then Row1 etc .

I have quickly fixed it for now by editing viewtopic.php to look like this.

# Again this will be handled by the templating code at some point $row_color = ( !($i % 2) ) ? $bgcolor1 : $bgcolor1; $row_class = ( !($i % 2) ) ? 'row1' : 'row1';

I was just wondering how may sql queries this might generate, and if there was a better way to have all posts display the same? Like they do here.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


No SQL queries involved either ways.
You should modify template files instead of php files ... Confused

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


The easiest way Edit the CSS and use pseudo selectors:


.div_contaiting_the_post:nth-child(odd) {
background-color: green;
}

.div_contaiting_the_post:nth-child(even) {
background-color: pink;
}

This will work fine on "modern browsers", that means not in IE < 8.0.

Firefox, Chrome, Safari, Opera and IE 9 will be fine.

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Oh, I see what you mean now Nano, get rid of this in the template.

class="{postrow.ROW_CLASS}

Oh well, if no queries are used then its fine either way I guess.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


Editing CSS is a very valid alternative, but any css change will go site wide. Go the way suite you better.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

All times are UTC


Jump to: