Search code examples
yiipaginationcactivedataprovider

How to set current page with Yii's CActiveDataProvider?


I've created this CActiveDataProvider:

  $dataProvider=new CActiveDataProvider('Post',array(
    'criteria'=>array(
      'condition'=>$condition,
      'params'=>$params,
    ),
    'pagination'=>array(
      'pageSize'=>2,
    ),
  ));

but ... How can I define current page and load records 3,4 instead of 1,2? How can I get a precise page?


Solution

  • Set the zero-based currentPage attribute of the pagination

    ...
    'pagination'=>array(
      'pageSize'=>2,
      'currentPage'=>1,
    ),
    ...