码迷,mamicode.com
首页 > 其他好文 > 详细

Yii 之分页 + bootstrap

时间:2014-06-25 16:21:45      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:style   class   color   get   os   cti   

controller

$criteria = new CDbCriteria;

$criteria->order = ‘id asc‘; //这边还可以写其他的sql语句

$count = Bankinfo::model()->count($criteria);

$pages = new CPagination($count);
$pages->pageSize = 1;
$pages->applylimit($criteria);

$bankinfos = Bankinfo::model()->findAll($criteria);


$this->render(‘index‘, array(
‘bankinfos‘ => $bankinfos,
‘pages‘ => $pages,
));

 

view里

<div class="green-black">
<?php
$this->widget(‘MyLinkPager‘,array(
‘pages‘=>$pages,
));
?>
</div>

view里结合bootstrap          //蛋疼在只有 currentPage属性可用

<?php if($pages->pageCount > 1):?>
<div class="page_margin">
<ul class="pagination ">
<li class="<?php echo $pages->currentPage <= 0?‘disabled‘:‘‘; ?>"><a href="<?php echo $pages->currentPage <= 0?‘‘:$this->createUrl(‘bank/index‘,array(‘page‘=>$pages->currentPage));?>">&laquo;</a></li>
<?php for($i = 1;$i <= $pages->pageCount;$i++):?>
<li class="<?php echo $pages->currentPage +1 == $i?‘active‘:‘‘; ?>"><a href="<?php echo $this->createUrl(‘bank/index‘,array(‘page‘=>$i));?>"><?php echo $i; ?></a></li>
<?php endfor; ?>
<li class="<?php echo $pages->currentPage+1 >= $pages->pageCount?‘disabled‘:‘‘; ?>"><a href="<?php echo $pages->currentPage+1 >= $pages->pageCount?‘‘:$this->createUrl(‘bank/index‘,array(‘page‘=>$pages->currentPage+2));?>">&raquo;</a></li>
</ul>
</div>
<?php endif;?>

Yii 之分页 + bootstrap,布布扣,bubuko.com

Yii 之分页 + bootstrap

标签:style   class   color   get   os   cti   

原文地址:http://www.cnblogs.com/zhongyuan/p/3806239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!