Forums

New Where Conditions

grantdigital 15 Apr, 2019
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?
<?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);
?>
Max_admin 15 Apr, 2019
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
grantdigital 18 Apr, 2019
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.
Max_admin 18 Apr, 2019
So you want to build the conditions using PHP ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
healyhatman 18 Apr, 2019
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
Max_admin 22 Apr, 2019
Answer
I added support for custom rules in the next update!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 22 Apr, 2019
No problem!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.