Thinkphp template usage and content output instance, thinkphp template. The thinkphp template usage and content output example. the thinkphp template in this article describes the thinkphp template usage and content output. Share it with you for your reference. The specific analysis is as follows: 1. thinkphp template usage and content output instance, thinkphp Template
This example describes the thinkphp template usage and content output. Share it with you for your reference. The specific analysis is as follows:
I. template usage
A. rules
In the template folder, the [TPL]/folder with the same name as the module name [Index]/file with the same name as the module name should be index.html (. tpl)
In the template folder, [TPL]/[group folder/]/a folder with the same name as the module name [Index]/The file named ". tpl)
[TPL]/[group folder/] [template topic folder/]/folder with the same name as the module name [Index]/file with the same name as the module name (. tpl)
The difference here is that the design of the parent file directory is different. some grouping designs and application relationships (foreground applications and background applications) can be further divided into topic folders when designing templates for grouping.
Change the extension name of the template file (modify the configuration file)
The code is as follows:
'Tmpl _ TEMPLATE_SUFFIX '=> '.html', // modify the extension name of the template file
B. how to deal with the problem that the template directory is too deep? you can create a template name in the Tpl folder. for example: Index_index.html
1 'modify template file directory hierarchies
The code is as follows:
'Tmpl _ FILE_DEPR '=>' _ ', // modify the directory level of the template file. here _ is the underline in the corresponding template file name.
2. write a template file in it to use the newly created template file.
C. The template topic is similar to the theme of the QQ space. you can dynamically select the template topic file.
The code is as follows:
'Default _ THEME '=> 'your', // sets the DEFAULT template topic.
Create a new yourfile folder under tplas as a template topic folder, then create an indexfile folder and create index.html
How can I modify the template topic dynamically?
1. prepare a function in the background to modify the default template items in the config. php file.
2. pass the t = topic parameter through the url to modify different templates
The code is as follows:
'Default _ THEME '=> 'your', // sets the DEFAULT template topic.
'Tmpl _ DETECT_THEME '=> true, // automatically detects the template topic
'Theme _ list' => 'Ur, my', // LIST of supported template topics
Access Method: localhost/thinkphp/index. php/Index/index? T = you
Localhost/thinkphp/index. php/Index/index/t/you
You do not need to disable the template topic.
II. output template content
Display method:
1. no parameters in display
The code is as follows:
$ This-> display (); // template file with the same default call method
2. parameters can be included
The code is as follows:
$ This-> display (the specified template file in the folder of this module );
$ This-> display ('input2 ');
$ This-> display (other template files in other folders );
$ This-> display ('public: error'); // hide, always folder the publicfile under tplto include error.html. no Public module is required, as long as this folder is available.
$ This-> display (Template files in folders under other themes); // you need to enable topic support.
$ This-> display ('My: Index: index ');
I hope this article will help you with ThinkPHP framework programming.
Examples in this article describe the thinkphp template usage and content output. Share it with you for your reference. The specific analysis is as follows: 1. model...