Detailed thinkphp method to realize the static site

Source: Internet
Author: User
This article mainly introduced the thinkphp realization site static method, Thinkphp provides an effective method to generate static pages, with a certain reference value, interested in small partners can refer to.

Thinkphp provides a valid way to generate static pages, as explained in the Manual of Tp2.0, 3.0 of which are not described in the 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, the static file setting A/index. Then the saved path is the project path/html/a/index.html (the default static path is not created on the project path under the Html folder)

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 ');

Such three formats are equivalent

The following is a static implementation, with two methods

Can be added under the current module, such as the above statement, so long as the running of the module will produce the specified directory of "module. html" file, the usual practice is that the site after the construction, specifically write a method, and then let it execute, so that the entire site to generate 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 project must be emptied

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.