腐ru 2014-09-19 12:39:07 18430次浏览 4条评论 5 1 0

方法中写法:

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,
));?>
觉得很赞
您需要登录后才可以评论。登录 | 立即注册