One phpcodeigniter Problem

Source: Internet
Author: User
The view contains the description, keywords, contact, etc… of the webpage ....... These are stored in the database. How can they be called in the template by writing them in only one location? For example, & amp; lt ;? Phpecho $ system-& amp; gt; keywords ;? & Amp; gt; you can output keyword information without having to write the description, keywords, contact, etc… of the webpage in each controller ....... These exist in the database,
How can I call a template by writing it at only one position?

For example keywords;?>You can output the keyword information instead of writing it in each controller.

Reply content:

The view contains the description, keywords, contact, etc… of the webpage ....... These exist in the database,
How can I call a template by writing it at only one position?

For example keywords;?>You can output the keyword information instead of writing it in each controller.

You can use»Class Library Reference»Loader classInvarsMethod

Document address
The usage method is constructed in MY_controller.php:

$this->load->vars('yourglobalvars','yourvalues');

All your controllersInheritance MY_controllerIn this way, you can use this variable in all view templates that inherit the controller.


  yourglobalvars;?>

It can be placed in the cache and then pulled directly from the cache.

Try it.traitReusable code blocks. For more information, seePhp Manual

Customize the class and set the class to auto load when the database puts data
I wrote an article by referring to my blog.
Link

You can directly add $ this-> load-> view () to the 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.