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

Smarty BREAK ?

 
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 -> General
View previous topic :: View next topic  
Author Message
sarahfoxnz
Smarty Regular


Joined: 11 Apr 2010
Posts: 76

PostPosted: Sun Mar 12, 2017 9:45 pm    Post subject: Smarty BREAK ? Reply with quote

Smarty 2.6.26

Hi.

Ive done a bit of Googling & from what i understand, this is not yet in Smarty as a template.

I am currently doing a FOREACH

Code:
 {foreach from=$data key=k item=v}


Everything works fine, but if $k is the value "count", I want it to skip that iteration & go to the next item in that loop. the same as the PHP version of BREAK.

In my $data - i have various values for $k - But i do not want the 'count' to be displayed...

(all the values are multidimension arrays with $v being an array in an array - including 'count')
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Mar 12, 2017 10:17 pm    Post subject: Reply with quote

http://www.smarty.net/docs/en/language.function.foreach.tpl
Back to top
View user's profile Send private message
sarahfoxnz
Smarty Regular


Joined: 11 Apr 2010
Posts: 76

PostPosted: Sun Mar 12, 2017 10:57 pm    Post subject: Reply with quote

AnrDaemon wrote:
http://www.smarty.net/docs/en/language.function.foreach.tpl


From example 7.33 of the above, foreach else skips the foreach if the WHOLE data structure wants to be skipped.

Ie - do the foreach - if there is no data - do something else...


anyway, I solved my problem with an IF / elseif comamand.

Code:

{if $k eq 'count'}
{else}

Show code

{/if}



if $k is count - it skips that lime.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Mar 13, 2017 12:16 am    Post subject: Reply with quote

Did you read ENTIRE article?
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Mar 17, 2017 5:25 pm    Post subject: Reply with quote

You will want to study example 7.42.
Back to top
View user's profile Send private message
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 -> General 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