10、许愿墙实例讲解(3)判断是否Ajax提交与错误页面定制 笔记

浏览:1191 发布日期:2013/07/10 分类:技术分享
在结构文件中加入:
//点语法默认解析 - 加快模板的解析
'TEMP_VAR_IDENTIFY' =>'array',

配置 TMPL_FILE_DEPR参数 来减少目录层次,该参数默认是 “/”,如果改成

'TMPL_FILE_DEPR'=>'_'
那么分组的模板文件就变成了
Tpl/Home/Index_index.html
Tpl/Admin/User_index.html
为了得到地址,在index.js里加入:    <script type ="text/javascript">

        var handleurl = '{:U("Index/Index/handle",'','')}'; //在最新的3.1.3里,只写handle也OK

    </script>
为了该上handle方法被人单独访问,加入IS_AJAX判断

然后可以用结构文件定制错误页面

//指定错误页面模板路径

'TMPL_EXCEPTION_FILE' => './Public/Tpl/error.html',

error.html:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Document</title>

    <script type = "text/javascript">

        window.onload = function() {

            setTimeout(function () {

                window.location.href='<?php echo !-APP-!; ?>';

            }, 5000);

        }

    </script>

</head>

<body>

    <div>

        <p><?php echo $e['message'];?></p>

        <div>

            页面将在 5 秒后后跳转,或者点击<a href="<?php echo !-APP-!;?>">返回首页</a>

        </div>

    </div>

</body>

</html>
最佳答案
评论( 相关
后面还有条评论,点击查看>>