ThinkPHP template features

Source: Internet
Author: User
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.

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.