Updates on ExpressionEngine Conditionals
A couple of relevant updates for you on the changes with how ExpressionEngine 2.9+ handles conditionals.
Conditionals are parsed better, simple vs. advanced conditional is now a thing of the past, and there are some nice new operators; you can do simple math and more robust comparisons.
I was, admittedly, glossing over a big change in EE and one that impacts some third party developers. Fortunately, because of the Developer Preview Program all developers who participate had plenty of warning on this change. But it doesn’t mean that this will be a simple transition.
(A month ago, EllisLab wrote a good explanation of the changes to conditionals that is required reading for anyone working with EE.)
Already developers are posting updates for their add-ons to support the new conditional handling and they are trying to get the word out about how their add-ons are affected.
Low Schutte pondered:
Dilemma: update docs with the new conditionals & risk getting Qs from people not on 2.9, or stay with the old and risk the same? #eecms
— Lodewijk Schutte (@low) July 15, 2014
As I wrote in last week’s Content Mgmt Outlook email:
The forever problem of moving forward versus not leaving people behind.
Low also wrote up some instructions on how to use his Low Search add-on going forward:
Use the Matches operator instead of the IN operator in #eecms 2.9. Here’s how: http://t.co/5ecTN3O2CA
— Lodewijk Schutte (@low) July 16, 2014
And Mark Croxton, the wizard behind Stash, tweeted:
A note about conditionals in #eecms 2.9, and Stash: https://t.co/SDjR3cEd1F
— Mark Croxton (@croxton) July 16, 2014
Stash in 2.9 still works the same but Mark highlights an important workaround.
Mark also has an excellent explanation of the conditional parsing:
In 2.9 EE attempts to parse if/else conditionals before each pass and after the very last pass (or you can think of it as after each pass and before the very first pass), and will do so only if they are “ready” - the variables being evaluated actually exist. Previously, simple conditionals were parsed just before the first pass only, and advanced conditionals were parsed at the end of the very last pass only.
Some add-on updates may be backward incompatible (i.e. not support EE prior to 2.9), so always check the release notes before upgrading an add-on and not EE.