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