Thinkphp itself has a valid method of generating a static page, which is illustrated in the Manual of Tp2.0, which is not stated in the 3.0 manual, but the 3.0 method still exists. )
$this->buildhtml (' Static file ', ' Static path ', ' template file ');
A little explanation of the parameters, some friends asked me this parameter and how to use.
Parameter one: Static files, refers to the generated static file name, the file save path complete is: Static path/static file. For example, static file Settings A/index. Then the saved path is the item
Target path/html/a/index.html (default static path under the Html folder of the project path, no can be created by itself)
Parameter two: Static path, the above has explained the default path, 3.0 can add parameters in the Portal file to change the static path.
Define (' Html_path ', './'); (the static path is defined as the Web site root directory)
Parameter three: template file, I feel the official description is not correct, it should be the target module, is the module that needs to generate static files. Format: module name: operation. For example, to generate index under the A method is a static file, that is index:a. If empty, the static file for the current operation is generated by default.
Example:
Class Indexaction extends Action {public function index () { $this->buildhtml ("index", "'," "); $this, display (); } }
In fact
$this->buildhtml ("index", "," ");
$this->buildhtml ("index", "'," Index:index ");
$this->buildhtml ("index", "'," index ");
In this way three formats are equivalent
You can add a statement under the current module, so as long as the module is running, it will produce a "module. html" file in the specified directory, and the usual practice is to write a method after the site is built, and then let it execute so that the entire site generates static files at once. Note: If the site has edits or adjustments then you must clean the cache once, that is, the runtime folder under the item must be emptied.