2014-09-25 68 views
-1

我有一个很好的功能搜索工具,目前使用cakeDC搜索插件。我可以用分页进行很好的搜索。搜索不工作页面:2使用cakeDC搜索插件

我在这里的问题是,当我从页面搜索:2它根本没有。

这里是我的代码:

客户模式

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.

搜寻工作不页:2 ...

任何帮助将衷心appritiated ...谢谢你提前

+0

你能不能显示你的代码?如何搜索? – Sadikhasan 2014-09-25 10:27:46

+0

你没有任何第2页searchTerm'j',你可以重定向用户回搜索这样的案例 – Abhishek 2014-09-25 11:12:20

+0

@Sadikhasan我编辑了我的问题,并提供了搜索代码....实际上我已经使用cakeDC搜索插件。 – 2014-09-26 03:29:37

回答

1

尝试写这个代码创建表单

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

而不是

<?php echo $this->Form->create() ?> 
+0

谢谢,但它不工作 – 2014-10-06 05:37:23

0

我有同样的问题,当我从CakePHP 2.6分页与CakeDC插件的任何页面搜索时,我明白,页面:2或页面:3不存在,所以多数民众赞成在什么时候做一个搜索它标记为未找到,所以谢谢到Sadikhasan我改变了形式创造:

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

如果指数是我搜索使用的主要网页..