- 1 A Brief Introduction To The Secondary Development Of ZenTaoPHP
- 2. ZenTaoPHP Framework Extension Mechanism
- 3. ZenTaoPHP Framework API Mechanism
- 4 ZenTaoPHP Framework Command Line Mechanism
Extension Of View
There are two ways to extend the view file, one is to overwrite it completely and the second is to extend it through the hook mechanism.
1. Overwrite it completely
The override of the view file can be redefined by a complete override. For example, I'm going to extend the page Create in the Bug module, and the original view file is stored in module/bug/view/create.html.php. The only thing I need to do is copy the create.html.php to extension/custom/bug/ext/view/create.html.php, and then modify the page.
It should be noted that when copying and pasting, the including path needs to be changed accordingly.
2. Extending through the hook mechanism
The first method is simple and intuitive, but it has its disadvantage that the code cannot be reused. Assuming that there are changes in later versions, the view files of the old version may not be compatible with the programs of the new version. So you can consider code reuse through hook scripts. The naming convention of hook script is the method name. extension.html.hook.php. The hook file will be loaded after the entire template is loaded, and the corresponding php code or js code can be executed in it. This provides a mechanism to dynamically modify page elements through js, so as to achieve complete control over page elements.
For example, extension/custom/misc/ext/view/getsid.color.html.hook.php
Through the above js code, the red display of the top navigation bar is realized.