With this new where conditions I can see how to make conditions based on if a value is set or not.
I have filter options similar to the way the Joomla articles filtering works. I have a Published dropdown with 'All, Published & Unpublished' as options, a region dropdown with a number of regions and a keywords field to match the text of a number of fields.
The way I have set up is that I am using PHP to create and output the where list depending on what is set. Below is the code I am using to create the where conditions in the older versions. How can I dod this under the new system?
I have filter options similar to the way the Joomla articles filtering works. I have a Published dropdown with 'All, Published & Unpublished' as options, a region dropdown with a number of regions and a keywords field to match the text of a number of fields.
The way I have set up is that I am using PHP to create and output the where list depending on what is set. Below is the code I am using to create the where conditions in the older versions. How can I dod this under the new system?
<?php
$conditions = [];
$keywords = $this->data( 'keywords' );
$status = $this->data( 'status_filter' );
$region = $this->data( 'region_filter' );
switch ( $status ) {
case 'n' :
$conditions[] = 'Locations.state:0';
break;
case 'y' :
$conditions[] = 'Locations.state:1';
break;
default :
break;
}
if(!empty($region)){
$conditions[] = 'Locations.region:{data:region_filter}';
}
if ( ! empty( $keywords ) ) {
$search = '';
$search .= "Locations.name/like:%{data:keywords}%"
. "\nOR\nLocations.location/like:%{data:keywords}%"
. "\nOR\nLocations.time/like:%{data:keywords}%"
. "\nOR\nLocations.details/like:%{data:keywords}%";
if ( count( $conditions ) ) {
$conditions[] = "(\n" . $search . "\n)";
}
}
echo implode("\nAND\n",$conditions);
?>