At this point you can just alternate between values of "loop" or "loop1" in the "bg_class" key in your loop array. If you want to take that one step further, you could pull the class names and background colors themselves into your script, and replace them with template variables in the HTML. This way you could use an array of class name/color pairs which would be accessed by both the style section and the loop data structure. This would allow you to expand to an arbitrary number of background colors to be cycled through. Something like...<STYLE type="text/css"><!-- TD.loop1 { background-color: #c0c0c0; } TD.loop { background-color: #e0e0e0; } --></style> <TABLE border=0 cellspacing=0 cellpadding=3> <TMPL_LOOP name="some_loop"> <TR> <TD class=<TMPL_VAR name="class">> <TMPL_VAR name="content_column_1"> </td> <TD class=<TMPL_VAR name="class">> <TMPL_VAR name="content_column_2"> </td> <TR> </TMPL_LOOP> </table>
...for the style section. And...<STYLE type="text/css"><!-- <TMPL_LOOP name="style_loop"> TD.<TMPL_VAR name="class"> { background-color: <TMPL_VAR name="color"> +; } --></style>
...for the styles array. Then the main loop would use $styles[$n]->{class} to fill it's data structure, with $n cycling through each element of @styles.my @styles = ( { class => "bg_red", color => "#FF0000" }, { class => "bg_green", color => "#00FF00" }, { class => "bg_blue", color => "#0000FF" } );
Whoa... okay, so I got a little carried away here. This is probably more than you need, but that's where I'd go with it.
-Bird
In reply to Re: Loop Context Style with HTML::Template
by Bird
in thread Loop Context Style with HTML::Template
by gryphon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |