A PHP codeigniter problem

Source: Internet
Author: User
Tags vars codeigniter
There are pages in the view Description,keywords,contact,etc .... These are in the database,
How can I write it in one place and call it in a template?

keywords;?>For example, you can output keyword information without writing it in each controller

Reply content:

There are pages in the view Description,keywords,contact,etc .... These are in the database,
How can I write it in one place and call it in a template?

keywords;?>For example, you can output keyword information without writing it in each controller

You can use 类库参考 the»» 加载器类 vars method in

Document Address
Use the method in my_controller.php to construct the method:

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

All of your controllers 继承 MY_controller so that you can use this variable in all view templates that inherit the controller.


  
   yourglobalvars;?>

Can be placed in the cache and then pulled directly from the cache

You can try trait it and use it for reusable blocks of code, in detail to seephp手册

The custom class then puts the data in the database to set the class to load automatically
Refer to my blog to write an article
Link

$this->load->view () directly in 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.