Does ExpressionEngine support the "break" functionality in its loops?

{exp:channel entries
  channel="foo"
}
  {if some_arbitrary_condition}
    {!-- Do Break(exit the loop) --}
  {/if}
{/exp:channel entries}
up vote 0 down vote accepted

I found out that there is no break functionality for Expression Engine as of now.

The closest thing that can emulate it is using this code

{if count == "1"}
…output count here…
{/if}

It would still do the conditional for each iteration but you only execute the code inside once.

Thanks to @Bhaskar Yadav for the link

I think Mark Croxton's Switchee plugin might do what you're looking for, but not in that syntax. It'll let you create multiple case statements and also accepts regex patterns.

http://devot-ee.com/add-ons/switchee

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.