首页 > 技术文章 > 关于ThinPHP开启Smarty模板后,不能使用success、error方法解决方案

oyxp 2016-01-24 23:48 原文

解决方法:自己在入口文件定义一个方法,控制跳转,样式自己定义,哈哈!!!

 

index.php代码

<?php

// 开发调试模式true false 生产模式
define('APP_DEBUG',True);
define("HOME_IMG",'/shop/Home/Common/images/');
define("HOME_CSS",'/shop/Home/Common/css/');
define("HOME_JS",'/shop/Home/Common/js/');

define("ADMIN_VIEW",'/shop/Admin/Common/');

require_once '../ThinkPHP/ThinkPHP.php';

 

 

//跳转方法gotoURL

/*

**param $msg  跳转提示信息

**param $url    跳转url
**param $time  跳转时间

*/

function gotoURL( $msg , $url , $time){

     if(substr_count( $url , '/')<= 0 ){
      // url为 index形式,只有操作方法,分组控制器都相同
           $go = __CONTROLLER__.'/'.$url;
       }else if(substr_count( $url , '/') == 1){
     // url为 Index/index形式,只有分组相同
             $go = __MODULE__.'/'.$url;
                        }else{
       // url为 Admin/Index/index形式,分组、控制器、操作方法都不同,比如跳转到另一分组
   $go = 'http://'.$_SERVER['HTTP_HOST'].__ROOT__.'/index.php/'.$url;
   }

 

//跳转样式以及js

   echo "<p align='center'style='color:red;font-size:1.5em;margin:100px auto'>{$msg}</p><br /><p align='center'style='font-size:1.5em;margin:100px      auto'><i id='error_time' style='color:#D00;'>{$time}</i>秒后自动<a href='{$go}'>返回</a></p><script>setInterval(function(){document.getElementById('error_time').innerHTML -= 1;},1000)</script>";
header("refresh:{$time};url={$go}");
}

推荐阅读