2014-09-25 64 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'))); 

如果指數是我搜索使用的主要網頁..