News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Alternating row colours for topics

Started by ArrayInteractive, March 11, 2013, 01:34:36 PM

Previous topic - Next topic

ArrayInteractive

Wondering if anyone has an 'easy' way of doing this in 2.0.2

I would like to be able to alternate the colour backgrounds for each topic line.
ie: topic 1: bg=#000
     topic 2: bg=#FFF
     topic 3: bg=#000
     topic 4: bg=#FFF

It seems like I would need to find the loop that writes the <tr> tag and add an odd/even loop that adds a class to the< tr class="odd"> when it writes it. Then add some CSS for those new classes.

Just wanted to check if there was an already prescribed method, or if someone could point me to that <tr> function.

Thanks.
smf 2.0.2

Arantor

It's in the depths of your theme's MessageIndex.template.php, inside a foreach() covering... $context['topics'] I think it is.

ArrayInteractive

smf 2.0.2

ArrayInteractive

For reference, it's actually the <td>'s that would need to be styled for each row not the <tr>'s.
smf 2.0.2

Arantor

For reference, you can attach a style to the tr's provided that the td itself doesn't replace it.

There are times I've set the entire tr to windowbg or windowbg2 without setting a style per td ;)

ArrayInteractive

Ahh nice, I haven't tried that in a long time. Seems like at least once upon a time, TR styling was not supported in all browsers. I believe it may have been an IE6 thing. Anyway I'll give it a go.

smf 2.0.2

MrPhil

I think I've seen tr styling problems and limitations even in modern browsers. It's a tricky area, as <tr>s themselves don't display anything. However, you can see if properties are inherited by and from <tr>s.

Advertisement: