1
votes

I'm using the 2.0 version of cakephp search plugins by cakeDC (with cakephp 2.x)(https://github.com/CakeDC/search) . I'm need search in many models but thats models aren't related. So i create a new model (search) and a controller (searches) . I got this error

"Notice (8): Indirect modification of overloaded property SearchesController::$paginate has no effect [APP/Controller/SearchesController.php, line 17]"

Model:

App::uses('AppModel', 'Model');
class Search extends AppModel {
    public $actsAs = array('Search.Searchable');
    public $useTable = false;
    public $filterArgs = array(
        'terminada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.terminada',
                'SurfacesWater.terminada',
                'ResidualWater.termianda',
                'UndergroundWater.terminada',
                'PotableWater.terminada',
                'SpecifiedsResidualsWater.terminada'
            )
        ),
        'revisada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.revisada',
                'SurfacesWater.revisada',
                'ResidualWater.revisada',
                'UndergroundWater.revisada',
                'PotableWater.revisada',
                'SpecifiedsResidualsWater.revisada'
            )
        ),
        'eliminada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.eliminada',
                'SurfacesWater.eliminada',
                'ResidualWater.eliminada',
                'UndergroundWater.eliminada',
                'PotableWater.eliminada',
                'SpecifiedsResidualsWater.eliminada'
            )
        ),
    );
    public function orConditionsDates($data = array()) {
        $start = date('Y-m-d');
        $end = date('Y-m-d', strtotime('-1 month'));
        $cond = array(
            'OR' => array(
                $this->alias . '.monitoreofecha LIKE <=' => $end,
                $this->alias . '.monitoreofecha LIKE >=' => $start,
                ));

        return $cond;
    }
}

Controller:

App::uses('AppController', 'Controller');
class SearchesController extends AppController {
    public $components = array('Search.Prg');
    public $presetVars = true; // using the model configuration
    public function index() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Search->parseCriteria($this->passedArgs);
        $this->set('searches', $this->paginate());
    }
}

The view is the same of any index make with bake Any idea how what is my mistake? Thanks for all!!

S.

2

2 Answers

1
votes

if you do it this way you need to declare paginate first in your controller:

public $paginate = array();

or initialize it in your method directly

 $this->paginate = array();
0
votes

Try do it this way: App::uses('AppController', 'Controller');

class SearchesController extends AppController {
  public $components = array('Search.Prg');

  public $presetVars = true; // using the model configuration    

  public $paginate = array();

  public function index() {

    $this->Prg->commonProcess();

    $cond = $this->Search->parseCriteria($this->passedArgs);

    $this->set('searches', $this->paginate('Search', $cond));
  }
}