Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Alternating Colors
Chen
Join Date: Sep 2001
Posts: 5,393

by Chen Chen is offline 25 Feb 2002

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.
Views: 2466
Reply With Quote
Comments
  #2  
Old 27 Feb 2002, 14:16
DjSap DjSap is offline
 
Join Date: Nov 2001
thanks finally i can get that working
Reply With Quote
  #3  
Old 02 Mar 2002, 19:32
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
firefly you a genius I just did what I needed to do in seconds, I even amazed myself
Reply With Quote
  #4  
Old 10 Mar 2002, 18:17
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
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 10 Mar 2002, 18:31
Chen's Avatar
Chen Chen is offline
 
Join Date: Sep 2001
This is not a hack. You file hacks in the Full Releases forum, this just a forum to share small tips with other hackers.
__________________
Chen Avinadav
Formerly vBulletin.org Owner and Founder

chen@avinadav.com
Reply With Quote
  #6  
Old 10 Mar 2002, 18:40
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
thanks
Reply With Quote
  #7  
Old 21 Apr 2002, 04:00
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
could you maybe give a bit of help on how to implement this please?
Reply With Quote
Reply

Similar Article
Article Author Type Replies Last Post
[HowTo] Alternating colors for ONLY the postbit Floris vBulletin 2.x Full Releases 5 14 Feb 2004 01:01



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 07:31.

Layout Options | Width: Wide Color: