-1

I have a good functioning search tool at present using cakeDC search plugin. I can search very well with the pagination.

My problem here is that when i search from page:2 it doesn't at all.

here is my code:

Customer model

public $actsAs = array('Search.Searchable');
public $filterArgs = array(
    'searchTerm' => array(
        'type' => 'like',
        'field' => array('Customer.name', 'Customer.mobile', 'Customer.address'),
        'filter' => array('type' => 'query', 'method' => 'orConditions')
    )
);

public function orConditions($data = array()) {
    $filter = $data['filter'];
    $cond = array(
        'OR' => array(
            'Customer.name LIKE' => '%' . $filter . '%',
            'Customer.mobile LIKE' => '%' . $filter . '%',
            'Customer.address LIKE' => '%' . $filter . '%',
    ));
    return $cond;
}

CustomersController

 public $components = array('Paginator', 'Session', 'Search.Prg');

 public $presetVars = true;

 public function index() {
    $this->Prg->commonProcess();
    $this->paginate = array();
    $conditions = $this->Customer->parseCriteria($this->passedArgs);
    $this->Customer->recursive = 0;
    $this->paginate = array(
        'limit' => 5,
    );
    $this->set('customers', $this->paginate($this->modelClass, $conditions));
    $this->set('model', $this->modelClass);
}

index.ctp

<?php echo $this->Form->create() ?>
<?php echo $this->Form->input('searchTerm', array('class' => 'form-control','placeholder' => 'search for customer', 'label' => FALSE,'url' => array_merge(array('action' => 'index'), $this->params['pass']))); ?>
<?php echo $this->Form->end() ?>

Error: The requested address '/KPautos/products/index/page:2?searchTerm=j' was not found on this server.

Search is not working on page:2...

Any help would be heartily appritiated...Thank you in advance

4

2 回答 2

1

尝试编写此代码以创建表单

<?php echo $this->Form->create(null, array('type'=>'get','url' => array('page'=>'1')));?>

代替

<?php echo $this->Form->create() ?>
于 2014-09-26T03:52:25.887 回答
0

当我从使用 CakePHP 2.6 的 CakeDC 插件的分页中的任何页面搜索时,我遇到了同样的问题,我知道 page:2 或 page:3 不存在,所以这就是在进行搜索时它标记为 Not Found 的原因,所以感谢 Sadikhasan我将表单创建更改为:

echo $this->Form->create(null, array('novalidate' => true,'type'=>'get','url' => array('action'=>'index')));

其中 index 是我用于搜索的主要页面..

于 2016-05-12T18:49:57.377 回答