How to Set List filter value through php_event

sunnyjey

Active Member
I am looking to set custom value of list filter with the help of php_event list plugin. Is this possible ?

I have tried to put following codes in onload, preload and other event hooks, but not working. Searched forum and wiki but could not find the solution.

Code:
$firstFilterValue = 'pending';

$input = JFactory::getApplication()->input;
$filters = $input->get('fabrik___filter', array(), 'array');
$model->filters['origvalue'][] = $firstFilterValue;
$model->filters['filter'][] = $firstFilterValue;
$model->filters["filter"]['0'] = $firstFilterValue;
 
var_dump $model->filters with some filter values set in your list.
This is an array of arrays, the sub-arraykeys are changing depending on which filters are set etc.

You have to do something like
$k = array_search('533',$model->filters["elementid"]); to get the key of the filter settings of one element.
I could modify an existing filter (field element, field filter, not exact) with
Code:
if (count($model->filters)==0) return;
$k = array_search('533',$model->filters["elementid"]);
if ($k!== false) {
  $model->filters["sqlCond"][$k]="`land`.`name` LIKE '%spa%'";
  $model->filters["origvalue"][$k]="spa";
  $model->filters["filter"][$k]="'%spa%'";
  $model->filters["value"][$k]="'%spa%'";
}

in onFiltersGot.

I never tried to set a new filter, I assume you must set all of the keys in onFiltersGot or so.
So maybe
$model->filters["elementid"][] = your-element-id;
and all other keys.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top