For some pages with common attributes (such as footer), you can create a template separately and use the template inclusion function provided by ThinkPHP to include it. in this way, when you want to modify these public pages, you only need to modify the corresponding template without modifying every page.
For some pages with common attributes (such as footer), you can create a template separately and use the template inclusion function provided by ThinkPHP to include it. in this way, when you want to modify these public pages, you only need to modify the corresponding template without modifying every page.
The template contains the include keyword, which is described in the following six methods.
Contains other operation template files of the current module
Format:
Example:
Operation templates containing other modules
Format:
Example:
This example contains the header operation template of the Public module.
Tip:Like the template output, this method does not actually check whether the corresponding modules and operations exist. you only need to create the template according to the template definition rules (that is, the template actually exists ).
Use the complete file name to include
Format:
Example:
This method refers to server-side inclusion (server-side path), rather than a URL address. if the relative path is used, it is based on the project portal file location.
Note: In this method, the template file name must contain a suffix.
Module operation templates with other template themes
Format:
Example:
Use variables to control the template to be imported
Format:
Example:
Assign different values to $ tplName to include different template files.
Use shortcuts to include files
Format: {include: template file rules}
Example: The template file rules can use the five methods mentioned above.
Note: If the included template is changed, the template engine will not re-compile the template unless the cache has expired. Therefore, if you modify the contained external template file, you need to clear the module's cache Directory (RuntimeCache); otherwise, it will not take effect.