ThinkPHP3.2.2自定义success及error跳转页面

默认的thinkphp success及error的默认模板不是很好看,下面分享如何自定义success及error页面,这里用的是thinkphp 3.2.2版本
默认的thinkphp success及error的默认模板不是很好看,下面分享大家如何自定义success及error页面,这里用的是thinkphp 3.2.2版本 
首先在配置文件中添加以下代码(/Application/Admin/Conf/config.php)
//自定义success和error的提示页面模板
'TMPL_ACTION_SUCCESS'=>'Public:dispatch_jump',
'TMPL_ACTION_ERROR'=>'Public:dispatch_jump',
这里error和success是公用的一个模板文件,代码如下(/Application/Admin/View/Public/dispatch_jump.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>跳转提示</title>
    <style type="text/css">
    *{ padding: 0; margin: 0; }
    body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 6px; }

    .message{width: 400px;height: 150px;margin:auto;border:1px solid #1B8F24;margin-top: 30px;}
    .head{width: 100%;height: 30px;background: rgb(222,245,194);text-align: center;padding-top: 5px;}
    .content{height: 120px;width: 100%;}
    .success ,.error{text-align: center;margin-top: 30px;}
    .jump{text-align: center;margin-top: 20px;}
    </style>

    </head>

    <body>
    <div class="message">

    <div class="head"><span>Ace Admin提示信息:</span></div>

    <div class="content">

    <?php if(isset($message)) {?>

    <p class="success">:) <?php echo($message); ?></p>

    <?php }else{?>

    <p class="error">:( <?php echo($error); ?></p>

    <?php }?>

    <p class="detail"></p>

    <p class="jump">

    <a id="href" href="<?php echo($jumpUrl); ?>">如果你的浏览器没有自动跳转,请点击这里...</a>

    <br />

    等待时间: <b id="wait"><?php echo($waitSecond); ?></b>

    </p>

    </div>

    </div>

    <script type="text/javascript">

    (function(){

    var wait = document.getElementById('wait'),href = document.getElementById('href').href;

    var interval = setInterval(function(){

    var time = --wait.innerHTML;

    if(time <= 0) {

    location.href = href;

    clearInterval(interval);

    };

    }, 1000);

    })();

    </script>

    </body>

    </html>

使用smarty模板来解析程序的方法

先把配置改一下
'TMPL_ACTION_ERROR' => 'Public:error',
'TMPL_ACTION_SUCCESS' => 'Public:success',
然后在VIEW文件下创建一个Public文件夹 建两个html :success.html和error.html
把ThinkPHP/Tpl/dispatch_jump.tpl的内容复制过来
删除和替换里面的所有php标签,因为smarty是不认<?php ?>这玩意的
只要改成smarty认的标签就可以了。
比如你找到<?php echo($jumpUrl); ?>这个,我们把他替换成{$jumpUrl}就可以了,其他以此类推。

转载于:https://www.cnblogs.com/xynetstudio/p/7493285.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值