Thinkphp generates static file configuration $ this-& gt; buildHtml ('hello', 'user/', 'index'); is this produced under the user directory? Hello.shtml also has cache configuration. By the way, the production cache is configured. if it is not generated immediately, wait for a certain period of time to automatically produce static pages. if it is equivalent to thinkphp, the static file configuration will be generated.
$ This-> buildHtml ('hello', 'user/', 'index ');
In this way, it is produced in the user directory? Hello.shtml
Cache configuration
By the way, the production cache is configured to be a point, not to generate immediately. it is quite practical to automatically generate static pages at a certain time.
Configure in cofig. php
If (! Defined ('think _ path') exit ();
Return array (
? 'HTML _ CACHE_ON '=> true,
? 'HTML _ CACHE_TIME '=> 10, // The unit of time is second
? 'HTML _ READ_TYPE '=> 0,
);
?
?
?
--------------------------
?
Project in c:/www/Tp/admin/
The generated static file target c:/www/tp/html/
Use a function dirname to return the path of the file to be removed? For example, tp/dl/123.php? If dirname is used, the absolute path c:/tp/dl is returned.
Index. php entry file configuration
Important
Define ('web _ path', dirname (_ FILE __));
Define ('no _ CACHE_RUNTIME ', true); // debug
?
Config. php
Add project configuration to .htm
HTML_FILE_SUFFIX=> '.Htm'
?
In the controller, map is used.
Function create (){
// Echo THINK_PATH;
$ Path = dirname (WEB_PATH). '\ HTML \\';
// $ Path = dirname (WEB_PATH). '\ HTML ');
Echo $ path;
$ This-> buildHtml ('loves ', $ path, 'index ');
}
?
?
------------------------
?
1. put UrlcreateAction in the Web Project
Public function url_news_view (){
Header ("Content-Type: text/html; charset = utf-8 ");
$ Dirpath = dirname ($ _ SERVER ['script _ filename']). '/Html/'; // html root directory? Last/is required
$ News = M ('New ');
$ List = $ news-> select ();
Foreach ($ list as $ var ){
$ Id = $ var ['new _ id'];
$ This-> assign ('data', $ var );
Var_dump ($ id );
$ This-> buildHtml ("news/{$ var ['addtime']}", $ dirpath, "Index: news_view ");???
}
}
The content output by the Index: news_view operation template to generate a static page