thinkphp3.0的分组配置

根目录下新建home目录。

index.php入口文件

<?php

define('APP_DEBUG', true);  //开启错误调试

define('APP_NAME', 'App');  //项目的名称

define('APP_PATH','./'); //项目的目录

require './ThinkPHP/ThinkPHP.php';

?>

 

 

配置文件:

 'APP_GROUP_LIST'        => 'Home,Admin',  //设置项目分组

'DEFAULT_GROUP'         => 'Home',  //默认的分组名

 

//在Lib的Action下分别建立 Home和Admin 目录,他们对应各个项目。

//在Tpl下也分别建立Home和Admin 目录,

 

测试:在Action的Home下新建一个IndexAction.class.php文件

class IndexAction extends Action {    

     public function index()

      {         header("Content-Type:text/html; charset=utf-8");   $this->assign('title','测试的首页');   $this->assign('list','内容看看');   $this->display();           }  

      public function ff()

      {   header("Content-Type:text/html; charset=utf-8");    $this->assign('title','测试的goioioi');   $this->assign('list','liangfs杀到喀什');   $this->display();  }

      }

 

在Tpl的Home中也Index目录,目录下文件index.html 和 ff.html

在浏览器打开:

  http://localhost/home   则打开index.html页面,对应IndexAction的index方法【配置默认模块式index,默认的动作是index,默认的分组是home,所有可省略不写】

其实完整是这样的:http://localhost/home/index.php/home[分组名]/Index[模块名]/index[操作名,就是成员方法];

//http://域名/项目名/分组名/模块名/操作名/其他参数

上面的 模块名  需要大写,否则报错,因为配置默认'URL_CASE_INSENSITIVE'  => false,是区别大小写的,如果想要不区分大小写,吧这个配置改为true.

这样子的话,模块名就可以小写了。

同理,ff页面,可以:http://localhost/home/index.php/Index/ff; 就可以访问了

 

同理:admin目录中配置同样的。

则:http://localhost/home/index.php/admin[分组名]/Index/index

上面的分组名不能省,因为 默认的是home,  home可以省,这个就不能省。

 

ff页面http://localhost/home/index.php/admin[分组名]/Index/ff

 

ps:   url中的模块名 不区分大小写  一定要修改默认配置,否则输入小写出错不断

 

 

 

 

 

 

 

 

 

 

posted on 2013-04-19 17:18  paly76  阅读(207)  评论(0)    收藏  举报

导航