Home > Article > Backend Development > thinkphp template usage and content output examples, thinkphp template_PHP tutorial
The examples in this article describe the use of thinkphp templates and content output. Share it with everyone for your reference. The specific analysis is as follows:
1. How to use templates
a. Rules
Under the template folder [TPL] /Folder with the same name as the module name [Index]/File with the same name as the method name [index].html (.tpl)
Under the template folder [TPL]/[Group Folder/] /Folder with the same name as the module name [Index]/File with the same name as the method name [index].html (.tpl)
Under the template folder [TPL]/[Group Folder/][Template Theme Folder/] /Folder with the same name as the module name [Index]/File with the same name as the method name [index].html (.tpl)
The difference here is that the design of the upper-level file directory is different. Some grouping designs and application relationships (front-end applications and background applications) can be divided into theme folders when designing templates in groups.
Change the suffix of the template file (modify the configuration file)
b. How to deal with the problem of the template directory being too deep? You can create a template name_method name.html in the Tpl folder. For example: Index_index.html
1'Modify the template file directory hierarchy
2. Write the template file in it and you can use the newly created template file
c. Template theme is a theme similar to QQ space. Template theme files can be selected dynamically.
How to dynamically modify the template theme?
1. Prepare a function in the background and modify the default template item in the config.php file
2. Pass the t=theme parameter through the url to modify different templates
2. Output template content
display method:
1. There are no parameters in display
I hope this article will be helpful to everyone’s ThinkPHP framework programming.