Filters let you control data when working with dynamic elements. They are commonly used with templating tags in a page's markup, but can also be used in PHP scripts.
<h2>[? $arrPage['page_title'] ?]</h2>
Filters take the form of PHP arrays, and are structured so that they can be read left-to-right (or top-to-bottom, as with the following examples). The following examples should illustrate how their structure allows for both simple and complex filters:
Show me pages that are visible in navigation:
array('page_is_hidden_in_navigation', '=', '0')
Show me pages that are visible in navigation and have a page icon:
array('page_is_hidden_in_navigation', '=', '0'),
array('page_icon', '!=', null)
Order Of Operations
When writing complex conditions that contain both AND and OR operations, it's essential to be aware of the priority in which they are evaluated.
a AND b OR c AND d
The AND's are grouped before the OR's are grouped, similar to multiplication having a higher priority than addition in algebra:
(a * b) + (c * d)
(a AND b) OR (c AND d)
But what if we changed our condition to look like the following?
a OR b AND c OR d
According to the default order of operations, the condition would be evaluated as follows:
a OR (b AND c) OR d
If that's not what we want, we must change how our condition is grouped:
(a OR b) AND (c OR d)
Here is an example showing the array structure for a grouped condition:
array('data_a', '=', '1'),
array('data_b', '=', '1')
array('data_c', '=', '1'),
array('data_d', '=', '1')
Differences Between XML Control and PHP Filters
When defining filters using the datafilter attribute in your markup, you only need to worry about the filter condition array. However functions in the PHP API often expect a Properties Array, which contains a Filter Array plus extra properties.