pagination problem

I am trying to paginate articles but at all pages all articles are there.

what is wrong?


public function actionIndex() {

        if (!isset ($_GET['code']))

            $code=null;

        else {

            $code=$_GET['code'];

        }

        $cid=cats::model()->gerid($code);

        $criteria=new CDbCriteria;

        $criteria->condition='cat_id=:link';

        $criteria->params=array(':link'=>$cid);

        $criteria->order='art_short DESC';

      

            $postCount=Arts::model()->count($criteria);

$posts=Arts::model()->findAll($criteria);

        $pages=new CPagination($postCount);

        $pages->pageSize=$this->pageSize;

        $pages->applyLimit($criteria);

 

        $this->render('index',array(

               'posts'=>$posts,

                'pages'=>$pages,

        ));

      

    }

have you tried to populate your $post after you setup your $pages? What does the gerid() method represent? What value is $this->pageSize?

I actually set


 $pages->applyLimit($criteria);

 $criteria->limit =$this->pageSize;

 $criteria->offset=intval($pg);

 $posts=Arts::model()->findAll($criteria);

All my previous code was from blog demo, I do not know if I set it wrong.

so are you still experiencing a problem?

Since I set limit and offset , it is ok now

I have the same problem and trying to understand code.

What is $pg?


 if (!isset($_GET['page']))

            $pg=1;

        else

            $pg=  intval($_GET['page']);