目前的TP框架支持设置某个MODULE的控制器层次,但我的需要是只需要针对部分控制器实现分层,以下是我的解决方案。
目前的TP框架支持设置某个MODULE的控制器层次,但我的需要是只需要针对部分控制器实现分层,以下是我的解决方案。
找到文件:./ThinkPHP/Library/Think/Dispatcher.class.php 第213行
将 if(!defined('BIND_CONTROLLER')) {// 获取控制器<br>
if(C('CONTROLLER_LEVEL')>1){// 控制器层次<br>
$_GET[$varController] = implode('/',array_slice($paths,0,C('CONTROLLER_LEVEL')));<br>
$paths = array_slice($paths, C('CONTROLLER_LEVEL'));<br>
}else{<br>
$_GET[$varController] = array_shift($paths);<br>
}<br>
}
修改成 if(!defined('BIND_CONTROLLER')) {// 获取控制器<br>
//增加局部设置控制器层次<br>
$partLevel = C('CONTROLLER_PART_LEVELS.'.MODULE_NAME.'/'.ucfirst(implode('',array_slice($paths,0,1))));<br>
if($partLevel && $partLevel > 1){<br>
$_GET[$varController] = implode('/',array_slice($paths,0,$partLevel));<br>
$paths = array_slice($paths, $partLevel);<br>
}elseif(C('CONTROLLER_LEVEL')>1){// 控制器层次<br>
$_GET[$varController] = implode('/',array_slice($paths,0,C('CONTROLLER_LEVEL')));<br>
$paths = array_slice($paths, C('CONTROLLER_LEVEL'));<br>
}else{<br>
$_GET[$varController] = array_shift($paths);<br>
}<br>
}
并在配置文件中增加 'CONTROLLER_PART_LEVELS' => array(<br>
'Www/Widget' => '2',<br>
),
即可对单独某个控制器设置控制器层次
如上述代码,则是为Www模块下的Widget控制器单独设置其控制器层次为2
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor