Static data configuration generated by thinkphp

Source: Internet
Author: User
Thinkphp generates static file configuration $ this-& gt; buildHtml (hello, user, index); is it produced under the user directory? Hello.shtml also has cache configuration. By the way, the production cache configuration is clicked. it is not generated immediately. when the automatic production of static pages reaches a certain time, it is quite practical to configure if (in cofig. php (! Defined (THINK_P thinkphp generate static file configuration

$ 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

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.