dimis283
(Dimis283)
1
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,
));
}
bettor
(Live Webscore)
2
have you tried to populate your $post after you setup your $pages? What does the gerid() method represent? What value is $this->pageSize?
dimis283
(Dimis283)
3
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.
bettor
(Live Webscore)
4
so are you still experiencing a problem?
dimis283
(Dimis283)
5
Since I set limit and offset , it is ok now
gposse
(Gposse)
6
I have the same problem and trying to understand code.
What is $pg?
dimis283
(Dimis283)
7
if (!isset($_GET['page']))
$pg=1;
else
$pg= intval($_GET['page']);