-----Original Message----- From: Stefan Sturm [mailto:stefan@urkman.de] Sent: dinsdag 6 augustus 2002 11:51 To: smarty-general@lists.php.net Subject: [SMARTY] break out of foreach-loop
Hello list,
my question:
I have a foreach-loop. How can I break this loop before it ends?
Ferdinand Beyer 6 August 2002 15:27:19 [ permanent link ]
On 6 Aug 2002 at 12:38, Peter Billen wrote:
break; ?
I think that guy means a {foreach} tag inside a template .
Well the answer is easy - such a function is missing. If you really need it (normally such logic should be in your php scripts, not in your templates...), write your own (compiler) plugins for that.
<?php // compiler.break.php function smarty_compiler_break($contents, &$smarty) { return 'break;'; }
?> <?php //compiler.continue.php function smarty_compiler_continue($contents, &$smarty) { return 'continue;'; }
?>
Create these two files and put them into your plugins directory (notice the naming convention compiler.xxx.php). Now, you should be able to leave foreach and section loops with {break} and to leave out one step with {continue}.
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .