YII框架组件CListView实现分页

时间:2024-01-20 09:39:27

效果是普通分页就不截图了。。。

C控制器方法如下:

$criteria=new CDbCriteria;
$criteria->condition = "`status`={$newStatus}";
$criteria->order = 'refresh_time desc';
$criteria->addCondition('user_id='.$user_id); $dataProvider = new CActiveDataProvider('Job', array(
'pagination' => array(
'pageSize' => 10,
),
'criteria' => $criteria,
)); $this->render('hrjob', array(
'dataProvider'=>$dataProvider,
'status'=>$status,
));

V 视图如下:

<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'id'=>'listview',
'itemsCssClass'=>'listview',
'template'=>"{summary}\n{sorter}\n{items}\n{pager}",
'pagerCssClass'=>'pager-box', 'itemView'=>'_hrjob',
'pager'=>array(
'id'=>'listviewpage',
'header'=>'',
'maxButtonCount'=>'8',
), )); ?>

在视图V中,_hrjob是分页内容(一个循环体),id为分页的样式

_hrjob视图如下:

<li onclick="show()">
<div class="hrresume-title">
<label><input name="hrresume[]" type="checkbox" value="<?php echo $data->id;?>"></label>
<span>职位:<?php echo $data->title;?></span>
<span class="date">刷新时间: <?php echo $data->refresh_time;?></span>
</div>
<div class="hrresume-con clearfix">
<div class="user-ico">
<img src="data:images/user-ico.gif" width="70">
</div>
<div class="baseinfo-con">
<p>
<span><a href="<?php echo CHtml::normalizeUrl(array("job/postsdetail", "id"=>$data->id));?>"><?php echo $data->title;?></a></span>
<span class="vertical-line">|</span>
<span><?php echo City::getCurrentCity($data->city);?></span>
</p>
<p>
<span><?php echo JobType::getTypeName($data->job_type_id);?></span>
<span class="vertical-line">·</span>
<span><?php echo $data->company_name;?></span>
</p>
<p>
<span><?php echo Datadict::item('hope_job_type',$data->hope_job_type);?></span>
<span class="vertical-line">·</span>
<span><?php echo Datadict::item('salary',$data->salary);?></span>
<span class="vertical-line">·</span>
<span><?php echo Datadict::item('work_year',$data->work_year);?></span>
<span class="vertical-line">·</span>
<span><?php echo Datadict::item('degree_val',$data->degree_val);?></span>
</p>
</div>
<div class="contact-con">
<p>应聘简历(1)</p>
<p><a href="<?php echo $this->createUrl('hrresume').'&job_id='.$data->id.'&status=1';?>">查看该职位所有简历</a></p> </div>
<div class="operate">
<a href="javascript:;" onclick="onRefresh(<?php echo $data->id;?>)">刷新</a>
<a href="<?php echo $this->createUrl('editjob').'&id='.$data->id;?>">编辑</a>
<a href="javascript:;" onclick="onDown(<?php echo $data->id;?>)"><?php if($status==1){echo '下线';}else{echo '上线';} ?></a>
</div>
</div>
</li>

相关文章