Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Alternating Colors
Admin's Avatar
Admin
Join Date: Oct 2023
Posts: 1

Admin

Server
Show Printable Version Email this Page Subscription
Admin Admin is offline 02-24-2002, 10:00 PM

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.
Reply With Quote
  #2  
Old 02-27-2002, 12:16 PM
DjSap DjSap is offline
 
Join Date: Nov 2001
Location: Stockholm, Sweden
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks finally i can get that working
Reply With Quote
  #3  
Old 03-02-2002, 05:32 PM
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
Location: UK
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

firefly you a genius I just did what I needed to do in seconds, I even amazed myself
Reply With Quote
  #4  
Old 03-10-2002, 04:17 PM
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
Location: Maryland
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 03-10-2002, 04:31 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is not a hack. You file hacks in the Full Releases forum, this just a forum to share small tips with other hackers.
Reply With Quote
  #6  
Old 03-10-2002, 04:40 PM
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
Location: Maryland
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks
Reply With Quote
  #7  
Old 04-21-2002, 02:00 AM
s o r o k a's Avatar
s o r o k a s o r o k a is offline
 
Join Date: Dec 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:16 AM.


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.04021 seconds
  • Memory Usage 2,250KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (6)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete