How can I horizontally alternate windowsbg & windowsbg2?

Started by RubberDucky, April 13, 2014, 08:46:28 PM

Previous topic - Next topic

RubberDucky

I'm not sure if this has been asked before, and I couldn't find it by searching for it, so I'll ask here:

I would like to know if it's possible to horizontally alternate windowsbg & windowsbg2, so every <tr> will have windowsbg, then windowsbg2, then windowsbg, then windowsbg2. Could anyone point me in the right direction?
My gaming forum: http://gamingforums.hostei.com. Please visit my gaming forum.
I want to become a bigforum when I grow up.

margarett

This is done is pretty much every table in SMF. Check BoardIndex.template.php as an example, but there are other places
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

RubberDucky

I found them in the template, but I would like to alternate them horizontally.

So the background color across the entire <tr> would alternate like this:

windowbg, windowbg, windowbg, windowbg, (this is a <tr></tr>)
windowbg2, windowbg2, windowbg2, windowbg2 (this is a <tr></tr>)
windowbg, windowbg, windowbg, windowbg, (this is a <tr></tr>)
windowbg2, windowbg2, windowbg2, windowbg2 (this is a <tr></tr>)
etc...

Right now it is like:
windowbg, windowbg2, windowbg, windowbg2 (this is a <tr></tr>)
windowbg, windowbg2, windowbg, windowbg2 (this is a <tr></tr>)
windowbg, windowbg2, windowbg, windowbg2 (this is a <tr></tr>)
windowbg, windowbg2, windowbg, windowbg2 (this is a <tr></tr>)
etc...

Is it possible to make it like this by editing the templates?
My gaming forum: http://gamingforums.hostei.com. Please visit my gaming forum.
I want to become a bigforum when I grow up.

margarett

Ah, yes, I see.

Well, that requires some "love" in coding it ;D plus having some caution about layout.

Taking, eg, BoardIndex.
Icon (on/off) is windowbg, description is windowbg2, and so on... If you do this in rows and if you have child boards, you will loose the visual separation that now exists.

Anyway, you can do something like this:
Find:
foreach ($category['boards'] as $board)
{

Add before:
$alternate = false;
And add after:
if ($alternate)
$class = 'windowbg';
else
$class = 'windowbg2';

Then you need to find and replace the adequate instances of class="windowbg" and class="windowbg2" with (note that in some places it's not just this, you need to adapt):
class="' . $class . '"
or, eg:
class="icon ' . $class . '"


And at the end of the foreach, ie, after this: <strong>', $txt['parent_boards'], '</strong>: ', implode(', ', $children), '
</td>
</tr>';
}

Add:
$alternate = !$alternate;

This needs to be done also in MessageIndex.template.php
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

RubberDucky

Oh boy, coding. I'm barely coming to grips with html and css, and now I need to copy and paste PHP.

Thanks for your post. I will try and implement the solution you gave me, and I will post again if I have any problems.
My gaming forum: http://gamingforums.hostei.com. Please visit my gaming forum.
I want to become a bigforum when I grow up.

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Advertisement: