0

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");
        }
    }
Community
  • 1
  • 1
squeaker
  • 395
  • 2
  • 7
  • 17
  • can't you just merge your condition with the conditions returned by search plugin? simething like `$conditions = array_merge('array('Listing.status_code' => 'drafts'), $conditions)` – arilia Oct 12 '13 at 21:44
  • Seems this works in app/Listingscontroller/: $conditions = array('conditions' => array($this->Listing->parseCriteria($this->passedArgs), array('not' => array('Listing.status_code' => '1')))); – squeaker Oct 13 '13 at 12:07

0 Answers0