Php-php advanced-How to reuse the head inside the thinkphp

Source: Internet
Author: User
Of course I know it's for Label, but the column of the head is taken out from the database, before the reuse of the most is also the view reuse, the column is not reusable, do you want to each controller inside the column out?

Reply content:

I certainly know is to use the label, but the column of the head is taken out from the database, before the kind of reuse is also the view reuse, the column is not reusable, do you want to each controller inside the column out?

You go to the header page to read the database, and then the header include to index not good.

With the TP pendant, directly call the pendant just fine

All classes inherit a core-written class, then query within the class, then $this->assign (' data ', $data);


  
    

所有controller继承一个 在commoncontroller里的构造方法写入你的查询需求即可

如果有方法临时不需要这个查询的话可以在子类中重新定义构造方法

建议模板插件用smarty,不要用tp自己的。

用block模板布局啊。固定头部和尾部。内容页继承就完事了。官方文档里面也有吧http://document.thinkphp.cn/manual_3_2.html#template_extend

或者你自己用前端框架来实现也可以。通过异步请求来加载内容页。

我们采用的是异步请求。简单粗暴。

  • 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.