[TriLUG] Smarty

Michael Kimsal mgkimsal at gmail.com
Thu Sep 19 13:41:13 EDT 2013


You'd likely need to create some other placeholder value that is checked
inside your iteration loop, and only process if the value is set to
something specific.  When a condition is met, change the placeholder value.
 The iteration will continue but skip over the actual logic.

Yeah, you could modify the DB call in this case, but being able to break
out of loops in general is a useful pattern, but AFAIK smarty doesn't
support it.  Groovy (java) doesn't either in its "each" iteration, which
bugs me.  :/



On Thu, Sep 19, 2013 at 11:45 AM, Brian McCullough <bdmc at buadh-brath.com>wrote:

> Drawing once again on the deep well of knowledge here, I have a question
> about Smarty.
>
> If there a "break" ( exit early ) statement in the "foreach" block in
> Smarty 2?
>
> I have been reading the documentation and I don't seem to see that kind
> of functionality.
>
>
> Basically, I have a database read providing the array of data being
> displayed, but I want to stop displaying after a certain number of
> items, rather than blindly displaying everything, no matter what.
>
>
> Thanks,
> Brian
>
>
> --
> This message was sent to: mgkimsal at gmail.com <mgkimsal at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web  :
> http://www.trilug.org/mailman/options/trilug/mgkimsal%40gmail.com
> Welcome to TriLUG: http://trilug.org/welcome
>



-- 
Michael Kimsal
http://michaelkimsal.com
919.827.4724


More information about the TriLUG mailing list