PDA

View Full Version : Alternating Row Color


SS9267547
02-15-2005, 11:59 AM
Morning all, I have a quick question about alternating row colors. How would I make this work on any page in vbulletin? I have this working in forumdisplay, showthread, etc but I can't get it to work for example under memberlist.php or online.php. All it does is show one color but doesn't alternate. This is what I've been using.

Example:

<if condition="exec_switch_bg()"></if>
<tr>
<td class="$bgclass" width="100" height="18">&nbsp; Text Here</td>
</tr>


Any help in the mater would be great, thanks.

deathemperor
02-15-2005, 02:33 PM
you need to modify no templates, just go to ACP --> Styles & Templates -> Style Manager -> Edit Main CSS --> now you just change the value in "Background" for Alt1 and Alt2 to the same then it would show the same color for row.

SS9267547
02-15-2005, 10:35 PM
Thanks for the reply but I don't think thats what I'm looking for. What I would like is to keep Alt1 and Alt2 different colors and have the rows alternate the colors so one if one row is white the next would be black and so forth.

trafix
02-15-2005, 10:39 PM
if (($counter++ % 2) != 0)
{
$backcolor = "class=\"alt1\"";
}
else
{
$backcolor = "class=\"alt2\"";
}

SS9267547
02-15-2005, 10:47 PM
Now I would insert the code into memberlist.php or whatever the file I need and not in the templates?

trafix
02-15-2005, 10:51 PM
correct

and your template bit would look something like

<tr>
<td align="center" $backcolor>
whatever
</td>

</tr>

SS9267547
02-15-2005, 11:07 PM
Ah what a pain. Still can't get it to work, seems to still display one color on all the rows. Dosn't matter what code I use, displays one or the other hehe. :speechless:

Adrian Schneider
02-16-2005, 12:06 AM
Here is what I used (the entire while statement)
while($app=$DB_site->fetch_array($getmiscapps))
{
if($col %2 == 0)
{
$color='alt1';
}
else
{
$color='alt2';
}
... CENSORED!
$col++;
}

Looks like you are just missing the $name++. :)

trafix
02-16-2005, 12:10 AM
Here is what I used (the entire while statement)
while($app=$DB_site->fetch_array($getmiscapps))
{
if($col %2 == 0)
{
$color='alt1';
}
else
{
$color='alt2';
}
... CENSORED!
$col++;
}

Looks like you are just missing the $name++. :)
thats the long way around .... i dont use it in a while loop ... and im not missing the $name++

but your code should still work :)

imported_infitech
10-29-2006, 10:27 AM
if (($counter++ % 2) != 0)
{
$backcolor = "class=\"alt1\"";
}
else
{
$backcolor = "class=\"alt2\"";
}

i tried to do this for every alternating tcat in my vbadvanced cmps by putting it in my forums/global.php and editing adv_porta;_module_shell here $mods[formcode]
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td colspan="$mods[colspan]" $backcolor> and it didnt work.... any ideas? im not a coder.