The foreachelse Function
The foreachelse function is used in conjunction with foreach, and operates much like the default tag does for strings, producing some alternative output if the array is empty. An example of a template using foreachelse follows:
{foreach key=key item=item from=$titles}
<p>No states matching your query were found.</p> {/foreach}
Note that foreachelse does not use a closing bracket; rather, it is embedded within foreach, much like an elseif is embedded within an if function.
Post a comment