Introducing Low List
One of the perks of being in the Developer Preview Program (DPP) is that I can test upcoming releases with my software. In fact, that’s the whole point of the DPP. The next version of ExpressionEngine is imminent, and it comes with a change that will affect one of my add-ons: Low Search.
If you ever used Low Search, you will be familiar with the IN conditionals, used primarily to set checked
and selected
attributes to your HTML. From a technical point of view, it is a cunning trick using EE’s infamous parse order to work around EE’s infamous parse order. However, when EE 2.9 hits the shelves, using this conditional syntax will throw an error.
All is not lost, though. 2.9 will let you use an alternative (slightly less user friendly) syntax to achieve the same result. But of course, this syntax is not supported in 2.8 and lower. How about a solution that works in the latest couple of EE releases, including the upcoming one? Here it is: Low List.
Low List is a new and free plugin that combines the basic functionality of Loopee and Low Search’s IN conditionals. It can loop and search through a list of character-separated items. That means you can replace this code:
<select name="category[]" multiple>
{exp:channel:categories channel="news" style="linear"}
<option value="{category_id}"{if category_id IN ({low_search_category})} selected{/if}>{category_name}<option>
{/exp:channel:categories}
</select>
With this:
<select name="category[]" multiple>
{exp:channel:categories channel="news" style="linear"}
<option value="{category_id}"{exp:low_list:has value="{category_id}" items="{low_search_category}"} selected{/exp:low_list:has}>{category_name}<option>
{/exp:channel:categories}
</select>
Slightly more verbose, but at least this will work across the board. If you’re already using Low Search, consider changing the IN conditionals to the Low List version.