Hello
I am struggeling with "beforesearch" (code pack) on al list & search type to set a value before search. But I did not found any hint or help on seblod.com. I tried to add code on the "hidden" part on the search form, but now result so far.
What I want to achieve:
I want to filter a list of articles with two dates. The articles are about "events" of our club. Some events have an start and end date, some only a start date. Events with a start date in the past should be filtered out, expect if the there is an end date which lies in the future. Therefore I want to use the value of the end date for the search filter instead of the start date. End date is 0000-00-00 00:00:00 eg. empty when not used.
I tried to add a beforesearch field with the following code:
$start = $fields['event_date_start']->value;
$end = $fields['event_date_end']->value;
if ($end == 0) {
$fields['event_date_filter']->value = $start;
} elseif ($end !== 0) {
$fields['event_date_filter']->value = $end;
}
I added in the "main" part of the search form a "JForm calendar" field "event_date_filter" an set 3 to "Future (> or =)" and the live value to "1 day -1 day".
I know how to use "beforerender" and I had no problem so far with the code pack. But beforesearch is a riddle for me...
kind regards
Michael