您好我目前正在为我的 CakePHP(2.2 应用程序)使用 CakeDC 搜索插件。
搜索工具本身工作正常,但是在搜索分页之前我无法获得结果或页面上显示的数据。
这是我的代码
模型:
// Configure Meio file uploader
var $actsAs = array(
'MeioUpload.MeioUpload' => array(
'filename' => array(
'allowedMime' => array('image/jpeg', 'image/pjpeg', 'image/png', 'application/pdf'),
'allowedExt' => array('.jpg', '.jpeg', '.png', '.pdf'),
'maxSize' => '8 Mb'
)
),
'Search.Searchable'
);
// Search plugin filters
public $filterArgs = array(
'title' => array('type' => 'like'),
'live' => array('type' => 'value'),
'search' => array('type' => 'like', 'field' => 'FaqArticle.description'),
'error' => array('type' => 'like'),
'description' => array('type' => 'like')
);
控制器:
// Search plugin
public $components = array('Search.Prg');
public $presetVars = true; // using the model configuration
public function admin_index() {
$this->Prg->commonProcess();
$this->paginate = array('conditions' => $this->FaqArticle->parseCriteria($this->passedArgs));
$this->set('faqArticles', $this->paginate());
// Count all live articles for intro text
$this->set('liveArticles', $this->FaqArticle->find('count', array('conditions' => array('FaqArticle.live' => '1')
)));
// Count all articles for intro text
$this->set('countedArticles', $this->FaqArticle->find('count'));
// Set searched for details
$this->set('searchedFor', $this->passedArgs);
// Set layout
$this->layout = 'admin';
}
看法:
<div class="pagination">
<ul>
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => '', 'currentClass' => 'active', 'modulus' => '5'));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</ul>