Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: RubberDucky on April 13, 2014, 08:46:28 PM

Title: How can I horizontally alternate windowsbg & windowsbg2?
Post by: RubberDucky on April 13, 2014, 08:46:28 PM
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?
Title: Re: How can I horizontally alternate windowsbg & windowsbg2?
Post by: margarett on April 13, 2014, 08:49:20 PM
This is done is pretty much every table in SMF. Check BoardIndex.template.php as an example, but there are other places
Title: Re: How can I horizontally alternate windowsbg & windowsbg2?
Post by: RubberDucky on April 14, 2014, 12:31:59 AM
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?
Title: Re: How can I horizontally alternate windowsbg & windowsbg2?
Post by: margarett on April 14, 2014, 07:22:11 AM
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
Title: Re: How can I horizontally alternate windowsbg & windowsbg2?
Post by: RubberDucky on April 15, 2014, 02:18:11 AM
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.
Title: Re: How can I horizontally alternate windowsbg & windowsbg2?
Post by: Deaks on April 20, 2014, 12:06:07 PM
RD did that work?