RE: breaking from loops
| From: | Travis Low | Date: | Wed, 27 Feb 2002 06:42:43 +0000 |
| Subject: | RE: breaking from loops | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2858@lists.php.net to get a copy of this message | ||
In my particular case, I'm porting a calendar screen to Smarty. After writing calendar screens in a variety of templating languages, I've concluded that the cleanest way to visually represent a Gregorian month is something like:
for i = 1 to 6
{
for j = 1 to 7
{
display days of month, padding rows as necessary.
}
break out if we've displayed all the days
}
The decision to display a Gregorian calendar month in grid format is a presentational decision, not a business decision. The desire to break out is motivated by the desire to not display a blank row. So I don't think it's appropriate for the data-driven PHP script to provide a row count for the loop. I'd rather decide in the template.
Even without this example, I think it would be a good idea to allow this capability. I'm not a designer, but it doesn't seem far-fetched that a designer might want to loop to create a design, but break on some dynamically determined value. Since I can't think of a good example, don't expect much of a debate from me on this point. :-)
cheers,
Travis
Andrei Zmievski wrote:
At 11:51 PM 2/26/02 -0600, Monte Ohrt wrote:-- Travis Low <mailto:travis@dawnstar.org> <http://dawnstar.org/travis>hmm, not currently one, but it would probably take about 5 minutes to write a {break} plugin function. ;-) or if you're impatient, do {php} break; {/php}I have to question why he even needs this feature. Logic like this should most likely be in the PHP script that provides the data. What do you need it for exactly? -Andrei --- You are currently subscribed to smarty as: travis@dawnstar.org To unsubscribe send a blank email to $subst('Email.Unsub') Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/