View Full Version : Alternate rows ala SitePointForums
Mijae
01-12-2004, 03:58 AM
Anyone want to make a hack to have the tables show up as on http://www.sitepointforums.com/ ?
I tried with templates but couldnt get it to work, so I think someone will have to hack something :P
Zachery
01-12-2004, 04:59 AM
Anyone want to make a hack to have the tables show up as on http://www.sitepointforums.com/ ?
I tried with templates but couldnt get it to work, so I think someone will have to hack something :P
its just a condtitional altho i dont remember it ATM :)
Mijae
01-12-2004, 01:01 PM
its just a condtitional altho i dont remember it ATM :)
If you remember please post :P
Feran
01-12-2004, 01:30 PM
This is how I do it:
$alt_on=0;
while (outputting_threads_or_posts) {
if (!$alt_on) {
show_first_color;
$alt_on = 1;
}
else {
show_second_color;
$alt_on = 0;
}
}
Um, unless vBulletin catches the entire threads' posts' template at once and spits it out, catch it before it outputs each individual post, and alter.
Princeton
01-12-2004, 02:13 PM
<if condition="$forum[displayorder] % 2 == 0">alt1<else />alt2</if>
or you can add this to your files ... insert code before any eval(templates) that you want to alternate colors
// ######## GT OPTION
$bgclass = (++$i%2)?"alt1":"alt2";
// ######### END GT
TIP: For easier vb upgrading... never remove code from defualt vb files.
you should comment them out
// ##### GT DISABLE OPTION
//function existingcode(){
// print_no_permission();
//}
// ###### GT END
When adding code make it stand out.
// ###### GT OPTION
function newCode(){$goeshere;}
// ######### END GT
Mijae
01-12-2004, 02:22 PM
<if condition="$forum[displayorder] % 2 == 0">alt1<else />alt2</if>
Where do I add that?
Boofo
01-12-2004, 02:36 PM
Remember when using this that the display order in the forums HAS to be numbered like this:
101
102
103
104
If you number your forums like I used to:
100
110
120
130
it won't work.
NTLDR
01-12-2004, 03:10 PM
All the code here is pretty redundant, vB3 has a function already to switch the background colors: exec_switch_bg() and use $bgclass in place of alt1/alt2 in the HTML.
Boofo
01-12-2004, 03:22 PM
All the code here is pretty redundant, vB3 has a function already to switch the background colors: exec_switch_bg() and use $bgclass in place of alt1/alt2 in the HTML.
But not in templates. You have to edit files for that. Editing templates is much easier and better if you ever have to upgrade. ;)
NTLDR
01-12-2004, 03:24 PM
<if condition="exec_switch_bg()">
No file mods there ;) And I'm sure it still works in vB3 RC1/2.
Boofo
01-12-2004, 03:29 PM
<if condition="exec_switch_bg()">
No file mods there ;) And I'm sure it still works in vB3 RC1/2.
Ok, how would you set up a template with this and the bgclass?
NTLDR
01-12-2004, 03:32 PM
<if condition="exec_switch_bg()">
<div class="$bgclass">this will be alt1 or alt2</div>
</if>
<if condition="exec_switch_bg()">
<div class="$bgclass">this will be the other class</div>
</if>
Boofo
01-12-2004, 03:37 PM
<if condition="exec_switch_bg()">
<div class="$bgclass">this will be alt1 or alt2</div>
</if>
<if condition="exec_switch_bg()">
<div class="$bgclass">this will be the other class</div>
</if>
But how would you set the first one to be alt1? Do you have to add something to the stylesheet?
NTLDR
01-12-2004, 03:38 PM
It already knows what, if anything the previous one was, however I'm sure you can override it with a parameter, but I don't have a copy of functions.php with me at the moment.
Mijae
01-14-2004, 02:49 AM
It already knows what, if anything the previous one was, however I'm sure you can override it with a parameter, but I don't have a copy of functions.php with me at the moment.
Bah! I have my forumid's all messed up, so this wont work for me. Oh well, I didnt want to copy SPF anyways :P
n00belit3
02-09-2004, 07:24 PM
Any idea how i could make this work for posbit only?
Andreas
02-09-2004, 07:51 PM
Setting up an initial value should be as easy as
<if condition="$bgclass='alt2'">
<td class="$bgclass">This will be in alt2</b>
</if>
<if condition="exec_switch_bg()">
<td class="$bgclass">Now alternating the classes</td>
</if>
<if condition="exec_switch_bg()">
<td class="$bgclass">Now alternating the classes</td>
</if>
...
sabret00the
05-16-2004, 09:15 PM
is their a way to acheive this without all of the conditionals?
Berethorn
07-02-2004, 02:35 PM
Can someone explain carefully where to place all this code? I'm trying to get the post colors to alternate.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.