thinkphp模塊不存在怎么解決?
解決方案:
1.在applicationCommonController目錄下添加“EmptyBaseController.class.php”文件。? ??
<?php /** *@Author:HTL *@Email:Huangyuan413026@163.com *@DateTime:2015-07-1411:22:18 *@Description:空模板控制器 *@use:其他項目添加EmptyController文件并繼承該類即可 */namespace CommonController;useThinkController;class EmptyBaseController extendsController{function_initialize() {//項目配置文件中的配置項 $emptyPath=C("EMPTY_PATH");//如果未配置默認的地址 if(!$emptyPath || empty($emptyPath))$emptyPath="/";header("Location:".$emptyPath);exit(); } }
相關推薦:《ThinkPHP教程》
立即學習“PHP免費學習筆記(深入)”;
2.在所有項目的Controller目錄下添加EmptyController.class.php并繼承”CommonControllerEmptyBaseController“。? ? ? ? ? ? ? ?
<?php /** *@Author:HTL *@Email:Huangyuan413026@163.com *@DateTime:2015-07-1411:22:18 *@Description:空模板控制器,直接繼承CommonControllerEmptyBaseController即可 */namespace PortalController;class EmptyControllerextends CommonControllerEmptyBaseController{ function _initialize(){ parent::_initialize(); } }
3.在dataconfconfig.php里添加”?EMPTY_PATH?“項自定義當訪問不存在的模塊時需要跳轉的頁面。? ? ? ? ?
<?php return array('EMPTY_PATH'=>'/index.php',/*訪問不存在的模塊時跳轉的地址*///其他配置項);? >
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦