问题描述
- 我yii 配置的smarty 模板,yii如何结合smarty分页呢
-
我yii 配置的smarty 模板,yii如何结合smarty分页呢?谢谢方法中写法:
复制代码public function actionIndex(){
$categoryModel = Category::model();
$criteria = new CDbCriteria();
$criteria->order = 'id ASC';
$criteria->addCondition('status=1'); //根据条件查询
$count = Category::model()->count($criteria);
$pager = new CPagination($count);
$pager->pageSize=2;
$pager->applyLimit($criteria);
$categoryInfo = Category::model()->findAll($criteria);$this->render('index',array('pages'=>$pager,'categoryInfo'=>$categoryInfo));
}
view视图中的调用:
复制代码<?php $this->widget('CLinkPager',array(
'header'=>'',
'firstPageLabel' => '首页',
'lastPageLabel' => '最后一页',
'prevPageLabel' => '上一页',
'nextPageLabel' => '下一页',
'pages' => $pages,
'maxButtonCount'=>3,
)
);?>
时间: 2024-10-24 18:27:02