|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sun Mar 12, 2017 9:45 pm Post subject: Smarty BREAK ? |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sun Mar 12, 2017 10:57 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Mar 13, 2017 12:16 am Post subject: |
|
|
Did you read ENTIRE article? |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Mar 17, 2017 5:25 pm Post subject: |
|
|
You will want to study example 7.42. |
|
Back to top |
|
|
|
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
|