Recently I encountered a problem where many plug-ins of cakephp come with built-in template files, such as plugin/Users/View/Users/login. ctp, I want to rewrite login. but this plug-in is a git submodule. after modification, submodule cannot be used to sync code on other machines. I checked the View's
Recently I encountered a problem where many plug-ins of cakephp come with built-in template files, such as plugin/Users/View/Users/login. ctp, I want to rewrite login. but this plug-in is a git submodule. after modification, submodule cannot be used to sync code on other machines. I checked the source code of the View and implemented the following solution.
1. create app/View/Users/login. ctp
2. create app/View/AppVIew. php
[Php]View plaincopyprint?
-
- App: uses ('View', 'view ');
- Class AppView extends View {
- Protected function _ paths ($ plugin = null, $ cached = true ){
- Return array_unique (array_merge (
- App: path ('View '),
- Parent: _ paths ($ plugin, $ cached)
- ));
- }
- }
3. change app/Controller/AppController. php
[Php]View plaincopyprint?
- Class AppController extends Controller {
- Public $ viewClass = 'app ';
- }
class AppController extends Controller {public $viewClass = 'App';}
Now, you can freely rewrite the template in Plugin in app/View.