I had a problem with orCondition method. I'd like to create a simple search engine using this plugin in that way that I just want to find a phrase (same or similar) if it's in database in title and description, and I really don't know what am I doing wrong. Only effect I achived is I can find a title when I type it in form exactly in the same order as originally in database. For example if the post is titled "One two three" and I type "two" it works, but if I type "three two" there's no result. Here's some code.
Model:
public $actsAs = array('Search.Searchable');
public $filterArgs = array(
'title' => array('type' => 'query', 'method' => 'orConditions'),
'status' => array('type' => 'value'),
'category' => array('type' => 'value'),
'country' => array('type'=>'value'),
'continent' => array('type'=>'value'),
'cycle' => array('type'=>'value'),);
...
public function orConditions($data = array()) {
$title = $data['title'];
$cond = array(
'OR' => array(
$this->alias . '.title LIKE' => '%' . $title . '%',
$this->alias . '.description LIKE' => '%' . $title . '%',
));
return $cond;
}
View:
echo $this->Form->create('Ad', array('url' => array_merge(array('action' => 'index'), $this->params['pass'])));