Thinkphp provides an effective method to generate static pages (as described in the tp2.0 manual, not described in the 3.0 manual, but the 3.0 method still exists .) $ This-& gt; buildHtml (...
Thinkphp provides an effective method to generate static pages (as described in the tp2.0 manual, not described in the 3.0 manual, but the 3.0 method still exists .)
$ This-> buildHtml ('static file', 'static path', 'Template file ');
Some friends asked me how to use this parameter.
Parameter 1:A static file is the generated static file name. The Complete file storage path is: static path/static file. For example, if a/index is set for a static file, the saved path is an item.
Path/Html/a/index.html (the default static path is under the Html folder of the project path, and cannot be created by yourself)
Parameter 2:Static path. the default path is described above. in 3.0, you can add parameters to the entry file to change the static path.
Define ('HTML _ path', './'); (the static PATH is the root directory of the website)
Parameter 3:Template File. I think the official description is incorrect. for accuracy, it should be the target module, that is, the module for generating static files. Format: module name: Operation, for example, if the method a under the Index is to be generated is a static file, that is, Index: a. If it is null, the static file for the current operation is generated by default.
The sample code is as follows:
- Class IndexAction extends Action {
- Public function index (){
- $ This-> buildHtml ("index ",'',"");
- $ This-> display ();
- }
- }
Actually
$ This-> buildHtml ("index ",'',"");
$ This-> buildHtml ("index", ''," Index: index ");
$ This-> buildHtml ("index", ''," index ");
In this way, the three formats are equivalent. The following is the static implementation. There are two methods:
You can add a statement like a statement under the current module. if you run this module, the "cmd.html" file under the specified directory will be generated. the common practice is to write a method after the site is built, then let it execute and make the whole site generate static files at a time,Note:If the site has been edited or adjusted, the cache must be cleared once, that is, the Runtime folder under the project must be cleared.