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?
This is done is pretty much every table in SMF. Check BoardIndex.template.php as an example, but there are other places
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?
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
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.
RD did that work?