您的位置:首页 > 编程语言 > PHP开发

Yii-跳转页面-用法(仅限zyd项目)

2013-01-16 10:43 316 查看
控制器

方法1
//执行操作
if(Product::model()->updateAll($set,$criteria)){
//成功跳转
$this->render('../index/success',array('message'=>'恭喜,产品审核成功'));
exit;
}else{
//失败跳转
$this->render('../index/error',array('message'=>'对不起,产品审核操作失败,请稍后再试!'));
exit;
}


默认3秒后跳转到定义的第一个链接
$this->render('../index/success',array(
'message'=>'恭喜,宝贝信息发布成功',
'links'=>array(
array('浏览发布的产品','/company/product/update/id/'.$model->zp_id),
array('继续发布产品','/company/product/create/step/1'),
),
));
exit;


另一种js跳转方式,它会替代全部页面显示,没有布局文件,可用于ajax更新的时候错误跳转
if(!MemGroup::model()->exists($criteria)){
jsRedirect($url,'2','操作错误,选中项操作名不能为空','controllerActions');
exit;
}


视图页面

<!--操作成功 start-->
<div class="change_done bd_db">
<p>
<span class="ico_big ico_done"></span>
<span class="fw_b fs_14"><?php echo isset($message)?$message:'操作成功' ?></span>
</p>
<p class="line_30">现在去,
<?php
foreach($links as $link){
echo CHtml::link($link[0],$link[1],array('class'=>'c_06c mr10'));
}
?>
</p>
<p class="c_666 ml40">该页将在 <span id='setouttime'>3</span>秒后自动跳转!</p>
</div>
<!--操作成功 end-->

<script language=javascript>
var int=self.setInterval("countdown()",1000);
function countdown(){
var t=document.getElementById("setouttime").innerHTML-1;
document.getElementById("setouttime").innerHTML=t;
if(t===0){
location='<?php echo $links[0][1]?>';
}
}
</script>

效果图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: