1
我正在cakephp 2+项目中工作。我正在实施用于分类左右两个div组合中的产品列表的分页。我能够使左div,但不能正确的一个,因为抵消不能在分页设置。我需要在左边div中的半项和右边div中的半项,所以我可以设置限制但不能抵消。我怎样才能做到这一点?CakePHP分页与左右div组合
Controller code
public function index()
{
$rows=$this->Product->find('count', array('conditions'=>array('Product.allow'=>1)));
if($rows%2==0)
{
$this->paginate = array('conditions' => array('Product.allow'=>1,'limit'=>($rows/2));
$list_l = $this->paginate('Product');
$this->set('left_list',$list_l);
$this->paginate = array('conditions' => array('Product.allow'=>1,'limit'=>($rows/2), 'offset'=>$rows/2));
$list_r = $this->paginate('Product');
$this->set('right_list',$list_r);
}
else
{
$right_list=$this->Paginate('Product', array('Product.allow'=>1),array('limit'=>($rows-round($rows/2)), 'offset'=>round($rows/2)));
}
}
View Code
Foreach loop with array returned from controller
感谢mensch您的确切答复。我几乎完成了......将代码提供给将来的参考近.........再次感谢抱歉不能投票给你,因为我的repu却不允许这样做;) –