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

Przerwanie petli foreach

 
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 -> Language: Polish
View previous topic :: View next topic  
Author Message
Buster
Smarty n00b


Joined: 29 Apr 2008
Posts: 1

PostPosted: Tue Apr 29, 2008 7:19 pm    Post subject: Przerwanie petli foreach Reply with quote

Witam.
Jako, że jestem nowy, to chciałem się przywitać i wszystkich pozdrowić. No a, teraz do rzeczy. Jest sobie taki kawałek kodu:

Code:

        {foreach from=$kategorie item=k name=petla}
        <tr>
                {foreach from=$katzaz item=kz}
                    {if $kz.id_kategorii eq $k.id} {assign var='check' value='true'} {else} {assign var='check' value='false'} {/if}
                {/foreach}

                <td>
                        <input type="checkbox" name="kat[{$smarty.foreach.petla.index}]" value="{$k.id}" {if $check eq 'true'} checked="checked" {/if}/> {$k.nazwa_kategorii}
                </td>
                <td>
                        <label for="il[{$smarty.foreach.petla.index}]">Ilość zdjęć: </label><input type="text" name="il[{$smarty.foreach.petla.index}]" {if $check eq 'true'}value="{$kz.ilosc_zdjec}"{/if} />
                </td>
        </tr>
        {/foreach}



Interesuje mnie, czy jest możliwość, przerwania działania tej wewnętrznej pętli foreach, w przypadku gdy warunek jest prawdziwy???
Back to top
View user's profile Send private message
fornve
Smarty Rookie


Joined: 25 Apr 2008
Posts: 29
Location: Sheffield, UK

PostPosted: Sat May 03, 2008 9:00 am    Post subject: Reply with quote

Siema,

w wewnetrznej petli piszesz
{if $warunek}
{assign $smarty.foreach.petla.index=$smarty.foreach.petla.last}
{/if}

Wink
Back to top
View user's profile Send private message 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 -> Language: Polish 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