I'm sure there is a very simple answer to this, but I'm not seeing it!
I'm using cakeDC Search and want to add a fixed condition so that Listing.status_code = drafts
are never shown in the returned search.
I've looked at here: But as this field is not directly linked to a form input i'm unsure as to how to tie it into the filters as an AND statement?
Here is my code so far:
public $filterArgs = array(
'long_name' => array('type' => 'like','empty','true'),
'issue' => array('type' => 'like','empty','true'),
'page_quality_id' => array('type' => 'value','empty','true'),
'series_id' => array('type' => 'value','empty','true'),
'coverDateBetween' => array(
'type' => 'expression',
'method' => 'CoverDateRangeCondition',
'field' => 'Listing.cover_date BETWEEN ? AND ?',
),
);
public function CoverDateRangeCondition($data = array()){
if(strpos($data['coverDateBetween'], ' - ') !== false){
$tmp = explode(' - ', $data['coverDateBetween']);
$tmp[0] = $tmp[0]."-01-01";
$tmp[1] = $tmp[1]."-12-31";
return $tmp;
}else{
return array($data['coverDateBetween']."-01-01", $data['coverDateBetween']."-12-31");
}
}