WP-MVC:如何使用paginate方法执行连接?

时间:2012-08-23 15:24:55

标签: php wordpress

我正在使用WP MVC进行wordpress,并且遇到以下问题。这是一个示例场景。我想允许用户在事件index.php页面上搜索功能。例如,我希望他们能够通过场地或演讲者找到所有活动,并有场地和演讲者的下拉菜单。如何使用events_controller.php中的paginate函数?

这是当前的代码:     公共职能指数(){

$this->params['page'] = empty($this->params['page']) ? 1 : $this->params['page'];

    $this->params['conditions'] = array('is_public' => true);

    $collection = $this->model->paginate($this->params);

    $this->set('objects', $collection['objects']);
    $this->set_pagination($collection);

}

你如何告诉分页你要加入或更好地在这种情况下加入的地点和方式?

1 个答案:

答案 0 :(得分:0)

您需要先搜索场地和扬声器。

//Paginating by venue id
$this->params['conditions']['venue_id'] = $venue_id; //example
$collection = $this->model->paginate($this->params);

//paginating by speaker id
$this->params['conditions']['Speaker.id'] = $speaker_id; //example
$collection = $this->model->paginate($this->params);