Libraries, helpers, and hooks folders in the CI framework

Source: Internet
Author: User

1. library folder

If you want to extend the CI function, place your class library here. Note that this folder is composed of classes. You can see the notes for loading the library!

2. helper folder

If you need to use some functions to complete some small functions, put them here. Here we use procedural code rather than classes. Generally, helper is used for view,
The usage is as follows:

Copy codeThe Code is as follows:
$ This-> load-> helper ('filename ')

Filename is the name of the file corresponding to the helper function, excluding the _ helper. php extension. The file name should be saved as: filename_helper.php, put in the helper folder!

3. hooks folder

Store the hooks you have created. Hooks are the control methods used to load other files and cannot be called by controllers. They are automatically called by the system. When CodeIgniter
After running, it generates a special process.
Of course, you can customize some actions to replace some stages of the program running. For example, you can trigger your script before or after the controller is loaded, or at other times.

Seven CI mount points:

Pre_system

Early calls of system execution. No route or other processes are executed only when the benchmark and hooks classes are loaded.

Pre_controller

Call before calling any of your controllers. The basic class, route selection, and security check used at this time have been completed.

Post_controller_constructor

After your controller is instantiated, it is called before any method is called.

Post_controller

It is called after your controller is fully running.

Display_override

Overwrite the _ display () function to send the final page to the web browser at the end of the system execution. this allows you to display data in your own way. note that you need to reference the CI super object through $ this-> CI = & get_instance, then, the final data can be obtained by calling $ this-> CI-> output-> get_output.

Cache_override

You can call your own function to replace the _ display_cache () function in the output class. This allows you to use your own cache display method.

Post_system

After the final coloring page is sent to the browser, the browser receives the final data and calls
The following describes how to use hooks:

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.