vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Alternating Colors (https://vborg.vbsupport.ru/showthread.php?t=35421)

Admin 02-24-2002 10:00 PM

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")."\";");
}

At first we initalize $bgcounter to 0, so we know exactly what comes first (first or second color).

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. :)

DjSap 02-27-2002 12:16 PM

thanks finally i can get that working

Bald Bouncer 03-02-2002 05:32 PM

firefly you a genius I just did what I needed to do in seconds, I even amazed myself ;)

jjj0923 03-10-2002 04:17 PM

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

Admin 03-10-2002 04:31 PM

This is not a hack. You file hacks in the Full Releases forum, this just a forum to share small tips with other hackers. :)

jjj0923 03-10-2002 04:40 PM

thanks

s o r o k a 04-21-2002 02:00 AM

could you maybe give a bit of help on how to implement this please?


All times are GMT. The time now is 02:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02363 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete