thinkphp Include files

Source: Internet
Author: User

Include other template files in the current template file using the Include tag, label usage:

<file/>
Working with template expressions

Template expressions are defined as: module @ theme/controller/operation

For example:

<file= "Public/header"/>  //contains header template headers<   file= "Public/menu"/>  //Contains menu template menus<  file = "Blue/public/menu" /> //contains the menu template below the blue theme

You can include more than one template at a time, such as:

<file= "Public/header,public/menu"/>

Note that the method that contains the template file does not automatically call the controller, which means that the variable assignments in the other template files that are contained need to be done in the current operation.

Working with template files

You can include a template file name (including the full path) directly, for example:

<file= "./application/home/view/default/public/header.html"/>
Incoming parameters

Regardless of the way you use the external template, the include tag supports passing in parameters at the same time as the include file, for example, in the following example we passed the title and keywords variables when we included the header template:

<file= "Public/header"  title= "thinkphp frame"  keywords = "Open source Web development framework" />

You can use the title and keywords variables in the included header.html file, as follows:

<HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><title>[Title]</title><Metaname= "keywords"content= "[keywords]" /></Head>

Note: Because of the characteristics of template parsing, parsing starts from the portal template, and if the external template changes, the template engine does not recompile the template unless in debug mode or the cache has expired. If the included external template file is modified in deployment mode, the cache directory of the module needs to be emptied, otherwise it will not take effect.

thinkphp Include files

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.