Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Content Management System (http://www.go4expert.com/articles/cms/)
-   -   Alternating Colored Rows in vBulletin 4 [No Plugin] (http://www.go4expert.com/articles/alternating-colored-rows-vbulletin-4-t25160/)

shabbir 5Mar2011 13:52

Alternating Colored Rows in vBulletin 4 [No Plugin]
 
How to have alternating colored rows (and not columns) in vBulletin 4. After searching around, I found one by William, Very nice work. His solution is for vBulletin 3 but it can be easily ported to vBulletin 4. As I searched, I saw the problem is talked a lot in forums without any solution for vBulletin 4 and so I decided to put together a solution extending William's work.

1. Edit template forumhome_forumbit_level2_post



Add the following code at the top of the template.

Code:

<vb:if condition="$altrow =& $GLOBALS['altrow']"></vb:if>
<vb:if condition="!isset($altrow)">
    <vb:if condition="$altrow = 0"></vb:if>
</vb:if>
<vb:if condition="++$altrow % 2 == 0">
    <vb:if condition="$rowClass = 'alteven'"></vb:if>
<vb:else />
    <vb:if condition="$rowClass = 'altodd'"></vb:if>
</vb:if>

Credit for the above code goes to William and forumthemes.

Now change the first line (first line before inserting the above code) from

Code:

<li id="forum{vb:raw forum.forumid}" class="forumbit_post L2">
to
Code:

<li id="forum{vb:raw forum.forumid}" class="forumbit_post L2 {vb:raw $rowClass}">

2. Edit forumhome_forumbit_level1_post / _nopost



Add the following at the top of forumhome_forumbit_level1_post and forumhome_forumbit_level1_nopost template.

Code:

<vb:if condition="$altrow =& $GLOBALS['altrow']"></vb:if>
<vb:if condition="$altrow = 0"></vb:if>

3. Edit Stylevars



Edit forumrow_firstentry_background and forumrow_background stylevars and make it transparent by deleting Background Color and Background Image.

4.Edit CSS



Now add the following CSS in the additional.css template.

Code:

.altodd {background-color:#eee;}
.alteven {background-color:#fff;}

You can customize the above CSS as per your needs.

I hope this helps fellow vBulletin forum webmasters.

pankaj.sea 6Mar2011 08:08

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Nice tutorial Shabbir!
:)
This was a very common question for webmasters at vBulletin.Org forum! ;) Now it has a solution!!
Thanks!

shabbir 6Mar2011 09:00

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Thanks and if you see someone looking for something now you know what to do?

pankaj.sea 6Mar2011 09:03

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Quote:

Originally Posted by shabbir (Post 80311)
Thanks and if you see someone looking for something now you know what to do?

Sure... ;)

Adam H 30Apr2011 18:56

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
This is a great work around , however i can not seem to get it working on the forumdisplay page . I.e the sub forums above the threadbits, Any ideas ?

shabbir 1May2011 09:59

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
You should be. What are you trying on the forumdisplay? I tried myself and it just works fine

Adam H 1May2011 14:21

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Quote:

Originally Posted by shabbir (Post 82547)
You should be. What are you trying on the forumdisplay? I tried myself and it just works fine

I have just followed your instuctions above , the forumhome is working great however when i click a forum category which has sub forums those subforums are not styled in the same way, is there more code that i have to add to the forumdisplay template ?

shabbir 1May2011 16:27

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Quote:

Originally Posted by Adam H (Post 82551)
I have just followed your instuctions above , the forumhome is working great however when i click a forum category which has sub forums those subforums are not styled in the same way, is there more code that i have to add to the forumdisplay template ?

sub forums will work if they are at level1 but if you have them as level 2 then you may need to edit those templates. Also you can make the same logic even applied to showthread.

Adam H 1May2011 16:40

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Quote:

Originally Posted by shabbir (Post 82552)
sub forums will work if they are at level1 but if you have them as level 2 then you may need to edit those templates. Also you can make the same logic even applied to showthread.

I do not suppose you could tell me how to get the level 2 working and the showthread too ? I seem to be going around in circles when i edit certain templates.

So far i have edited what you have mentioned above :

forumhome_forumbit_level2_post

forumhome_forumbit_level1_post

forumhome_forumbit_level2_nopost

Adam H 1May2011 16:40

Re: Alternating Colored Rows in vBulletin 4 [No Plugin]
 
Sorry i meant :

forumhome_forumbit_level1_nopost not forumhome_forumbit_level2_nopost


All times are GMT +5.5. The time now is 20:15.