标签:
最近使用THINKCMF开发了一个企业网站,因为之前客户的域名变更过,然后就发现当某个模块不存在的时候就出现了空页面在 THINKPHP论坛 上有人说在项目里添加一个EmptyAction.class.php,然后再写业务逻辑,结果搞了好长时间我一直都没有找到Action目录最后才发现ThinkCmf使用的是Thinkphp3.2而作者写的是3.1在网上逛了半天也没有解决问题,不得已还是要自己出马
<?php/** *@Author:HTL *@Email:Huangyuan413026@163.com *@DateTime:2015-07-1411:22:18 *@Description:空模板控制器 *@use:其他项目添加EmptyController文件并继承该类即可 */namespace Common\Controller;useThink\Controller;class EmptyBaseController extendsController{function_initialize(){//项目配置文件中的配置项 $emptyPath=C("EMPTY_PATH");//如果未配置默认的地址 if(!$emptyPath || empty($emptyPath))$emptyPath="/";header("Location:".$emptyPath);exit(); } }
<?php/** *@Author:HTL *@Email:Huangyuan413026@163.com *@DateTime:2015-07-1411:22:18 *@Description:空模板控制器,直接继承\Common\Controller\EmptyBaseController即可 */namespace Portal\Controller;class EmptyControllerextends \Common\Controller\EmptyBaseController{ function _initialize(){ parent::_initialize(); } }
<?php return array(‘EMPTY_PATH‘=>‘/index.php‘,/*访问不存在的模块时跳转的地址*/ //其他配置项 );?
>
标签:
原文地址:http://www.cnblogs.com/huangtailang/p/4645097.html