In the CI framework, how do I encapsulate some common modules (such as the login verification module required for every page )?

Source: Internet
Author: User
A beginner learns the CI framework and has some common modules. To reduce the granularity, I want to encapsulate it. I wonder if you have any good and mature experience? A beginner learns the CI framework and has some common modules. To reduce the granularity, I want to encapsulate it. I wonder if you have any good and mature experience?

Reply content:

A beginner learns the CI framework and has some common modules. To reduce the granularity, I want to encapsulate it. I wonder if you have any good and mature experience?

Based on my practical experience, writing a separate model is the easiest way for beginners to understand.

Models can call each other, accept post data, and almost accept all operations of the controller, which also avoids the exposure risk of the controller. Of course, at least two lines of code are required for calling.

$ This-> load-> model ('safe '); $ this-> safe-> login (); // you can perform a jump operation under the login function in the safe model.

In fact, writing a library is the best choice for large projects, but it is difficult for new users to understand and operate. You can try the model first and then the library.

Written in the model or under libraries

You can put these things in a public control or library. For this information, you can go to the CI official website to find more information.

Write a public Control, integrate the verification module, and then the other Control inherits it

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.