关于ThinPHP开启Smarty模板后,不能使用success、error方法解决方案
2016-01-24 23:48
791 查看
解决方法:自己在入口文件定义一个方法,控制跳转,样式自己定义,哈哈!!!
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}");
}
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}");
}
相关文章推荐
- php-empty()函数的一个小坑
- 命令行向Php传递参数的两种方式
- Php中heredoc与nowdoc的使用方法
- PHP——数组2(数组函数,二维数组,正则表达式)
- PHP-文件上传到独立服务器
- php面向对象基础部分
- vsftp,samba,nfs区别和配置
- PHP send email configuration in XAMPP
- 93. php 命名空间(3)
- openwrt 安装 php sqlite
- 如何解决PHP里大量数据循环时内存耗尽的问题
- PHP——简单的表单提交
- IIS下PHP运行环境搭建与网页服务器故障排查方法
- PHP——数组中的each(),list()和while循环遍历数组
- php 2015 年最热门的 10 篇技术文章
- 快速排序的php实现
- Thinkphp源码分析-命名空间自动加载
- PHP 魔术方法
- 【转】WordPress转PHPCMS策略-数据库完美转换
- php课程---数组建立表单