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);
?>
Each condition has a "null value" setting, if you set this to "continue" then the condition will be ignored if the value is null, could you please try that and let me know if you it can do what you need ? because you have a complicated conditions list!
Best regards
Best regards
Actually, that won't work as the status 'Listing.state' state condition has '=' test if an option is set or '>' when no options are set and no if all is selected. This is the same way Joomla shows publish and unpublished articles by default, then you can select 'all, published, unpublished, trashed or archived' to filter the list of articles.
So with the new 'Where conditions' select you have taken at any option of creating a condition that has different test types.
So with the new 'Where conditions' select you have taken at any option of creating a condition that has different test types.
So you want to build the conditions using PHP ?
If you're building the conditions with PHP you might as well just take the next step and do the data read with PHP too, but it would be nice to have the ability to have manual conditions, especially given the thing I emailed you about.
That being said, all of those conditions CAN be done with the current setup, just need some switches at the start
That being said, all of those conditions CAN be done with the current setup, just need some switches at the start
I added support for custom rules in the next update!
Best regards
Best regards
Thanks Max.
No problem!🙂
This topic is locked and no more replies can be posted.