Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Cycle ordering switches according to color

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
demagogue
Smarty n00b


Joined: 27 Oct 2004
Posts: 1

PostPosted: Wed Oct 27, 2004 7:03 pm    Post subject: Cycle ordering switches according to color Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Oct 27, 2004 7:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 27, 2004 7:39 pm    Post subject: Reply with quote

maybe your cycle is interfering with other cycles on the page. use a distinct cycle-name to prevent that.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP