Cakephp CakeDC搜索插件分页不工作
嗨,我目前正在为我的CakePHP(2.2应用程序)使用CakeDC搜索插件 搜索工具本身工作正常,但在搜索分页之前,我无法获得页面上显示的结果或数据 这是我的密码 型号:Cakephp CakeDC搜索插件分页不工作,cakephp,cakedc,Cakephp,Cakedc,嗨,我目前正在为我的CakePHP(2.2应用程序)使用CakeDC搜索插件 搜索工具本身工作正常,但在搜索分页之前,我无法获得页面上显示的结果或数据 这是我的密码 型号: // Configure Meio file uploader var $actsAs = array( 'MeioUpload.MeioUpload' => array( 'filename' => array( 'allowedMime' => ar
// 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';
}
视图:
此代码:
public $components = array('Search.Prg');
public $presetVars = true; // using the model configuration
应该在控制器中,而不是模型中。模型没有“组件”。控制器具有“组件”。并检查Serach插件的文档-模型中有$filterArgs(您已经正确地完成了),但控制器中有$presetVars
不要将$presetVars设置为空数组。只需将其从模型移动到控制器。正如您在模型中所做的那样,它应该在顶部声明为公共var,而不应该在admin_index方法中声明。会发生什么?您会遇到什么错误?没有错误,常见问题解答文章表不会分页。请尝试设置
public$presetVars=array()
和do$this->Prg->commonProcess('SearchModel')代码>并查看是否有帮助。我添加了$presetVars=array()$此->Prg->commonProcess('FaqArticle');对于控制器功能,如果运气不好,则不分页。还有其他建议吗?你能解释一下“没有分页”是什么意思吗?你有什么数据吗?第一页?嗨,谢谢你的回复。我已经更新了代码以反映您的更改,但没有任何更改。(更新上述代码以反映变化)还有其他想法吗?它既不在页面加载上也不在搜索上分页。不是真的,对不起。我刚刚在Cake 2.2中使用了分页功能,所以我认为插件本身并没有损坏。我将尽可能地简化案例,然后查看SQL日志。注释掉负载行为。从控制器和视图中注释掉实时文章、计数文章等。然后尝试只搜索一个字段-标题。查看生成的SQL等。进行打印($this->paginate);调用$this->paginate=array('conditions'=>$this->FaqArticle->parseCriteria($this->passedArgs))之后;让一个最简单的案例生效,然后再添加一些内容。
public $components = array('Search.Prg');
public $presetVars = true; // using the model configuration