Rewrite the template file in CakephpPlugin

Source: Internet
Author: User
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?
  1. App: uses ('View', 'view ');
  2. Class AppView extends View {
  3. Protected function _ paths ($ plugin = null, $ cached = true ){
  4. Return array_unique (array_merge (
  5. App: path ('View '),
  6. Parent: _ paths ($ plugin, $ cached)
  7. ));
  8. }
  9. }
 



3. change app/Controller/AppController. php




[Php]View plaincopyprint?
  1. Class AppController extends Controller {
  2. Public $ viewClass = 'app ';
  3. }
class AppController extends Controller {public $viewClass = 'App';}

Now, you can freely rewrite the template in Plugin in app/View.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.