|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
demagogue Smarty n00b
Joined: 27 Oct 2004 Posts: 1
|
Posted: Wed Oct 27, 2004 7:03 pm Post subject: Cycle ordering switches according to color |
|
|
Hello,
I think I may have discovered a small bug with {cycle}. When using the following code to alternate the background of a table, the first row starts with #ffffff, not #eeeeee:
Code: | {foreach name=outer key=year item=monthlytotal from=$monthlytotals}
{foreach key=key item=item from=$monthlytotal}
{cycle values="#eeeeee,#ffffff" assign="row_color"}
<tr bgcolor="{$row_color}">
<td>{$year} - {$key}</td>
<td>${$item}</td>
</tr>
{/foreach}
{/foreach} |
This is odd because when I use the same {cycle} values with a {section} block, the first row background starts with #eeeeee.
But here's the weird part: when I switch the first color value in the above foreach loop to #eeefee, the first row is now rendered with #eeefee, similar to what happens when using {cycle} with {section}. Weird.
Why would using a different color value affect the order in which {cycle} assigns values? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Oct 27, 2004 7:36 pm Post subject: |
|
|
Versions? Caching? Compile options? I can't reproduce this (I'm using the most current Smarty in CVS)
On another (unrelated) note, if you are not re-using the cycle, why not do something like:
Code: | {foreach key=key item=item from=$monthlytotal}
<tr style="background-color:{cycle values="#eeeeee,#ffffff"};">
<td>{$year} - {$key}</td>
<td>${$item}</td>
</tr>
{/foreach} | ?
(I tend to prefer CSS styling to bgcolor et al).
Last edited by boots on Wed Oct 27, 2004 7:46 pm; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 27, 2004 7:39 pm Post subject: |
|
|
maybe your cycle is interfering with other cycles on the page. use a distinct cycle-name to prevent that. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|