The Arcive of vBulletin Modifications Site. |
|
|
Alternating Colors
Ok this is a pretty old 'trick' but I'm bored so here goes. This is how you can get the effect of switching colors, like posts in vBulletin and such. Code:
$bits = '';
[high]$bgcounter = 0;[/high]
$result=$DB_site->query("SELECT * FROM table");
while ($row=$DB_site->fetch_array($result) and [high]++$bgcounter[/high]) {
[high] $bgcolor = iif($bgcounter%2==0, '{firstaltcolor}', '{secondaltcolor}');[/high]
eval("\$bits .= \"".gettemplate("template")."\";");
}
Then in the loop, we each time increment $bgcounter by one, so once it's an odd number and once it's even. And last, inside the loop we check every time wheter $bgcounter is even or odd. This is done using the modulus operator. If it's even, we get {firstaltcolor} in $bgcolor. Otherwise, we put there {secondaltcolor}. Then all there's left to do is use $bgcolor in the template, and you will once get the first alternating color, and once the second.
|
|
#2
|
|||
|
|||
|
thanks finally i can get that working
|
|
#3
|
||||
|
||||
|
firefly you a genius I just did what I needed to do in seconds, I even amazed myself
|
|
#4
|
||||
|
||||
|
pardon the newbie question, but I just installed purchased and installed vbulletin yesterday and I want to install this hack.
In which module do I install this code? thanks in advance and pardon my ignorance. all in all, I got purchased the product and had the forum up and running in about 3 hours... - jeff |
|
#5
|
||||
|
||||
|
This is not a hack. You file hacks in the Full Releases forum, this just a forum to share small tips with other hackers.
|
|
#6
|
||||
|
||||
|
thanks
|
|
#7
|
||||
|
||||
|
could you maybe give a bit of help on how to implement this please?
|
![]() |
|
|