thinkphp make each template page contain a header file and a footer file

Source: Internet
Author: User

In the process of development, often encountered to make each template page contains a header file and a footer file, thinkphp template layout provides us with a call to the global configuration method to solve the problem.

1. Turn on the layout_on parameter in the configuration file (not on by default) and set the layout entry file name Layout_name (default to Layout)

    ' layout_on ' =>true,    ' layout_name ' and ' LAYOUT ',

2. Create a layout.html file in the template directory with the following code in the file:

    <include file= "Public:header"/>    {__content__}    <include file= "Public:footer"/>

{__content__} is a specific word substitution string, if the template reads the layout template for user/add.html,thinkphp, the user/add.html template file is parsed and the parsed content is replaced with the layout template file { __CONTENT__} specific string.

3.

    ' Tmpl_layout_item '      = '  {__replace__} '//change this specific replacement string by setting

    ' Layout_name ' = ' layout/layoutname ',//Specify layout templates for other locations

A more detailed introduction: http://www.thinkphp.cn/info/183.html


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.