Smarty implements PHP static

Source: Internet
Author: User
There is a method fetch () in smarty to get the content of the template page. Its declaration is like this :? Phpfunctionfetch ($ resource_name, $ cache_idnull, $ compile_idnull, $ displayfalse )? The first parameter is the Template Name, the second parameter is the cache id, the third parameter is the compilation id, and the fourth parameter is

There is a method fetch () in smarty to get the content of the template page. Its declaration is like this :? Php function fetch ($ resource_name, $ cache_id = null, $ compile_id = null, $ display = false )? The first parameter is the Template Name, the second parameter is the cache id, the third parameter is the compilation id, and the fourth parameter is

There is a method fetch () in smarty to get the content of the template page. Its declaration is like this:

function fetch($resource_name, $cache_id = null,
$compile_id = null, $display = false)

?>
The first parameter is the Template Name, the second parameter is the cache id, the third parameter is the compilation id, and the fourth parameter is whether to display the template content. this method is used to generate static pages.


$ Smarty = new Smarty ();
// Other template replacement syntax...

// The following sentence Retrieves all the content on the page. Note that the last parameter is false.
$ Content = $ smarty-> fetch ('template name. tpl', null, null, false );

// Write the content below to a static file
$ Fp = fopen('news.html ', 'w ');
Fwrite ($ fp, $ content );
Fclose ($ fp );

// OK. This news.html static page is generated here. You can handle your next step.
?>

You only need:

Code:



Create table news (
Id int unsgined not null primary key auto_increment,
Title varchar (255 ),
Author varchar (50 ),
Url varchar (100),/* Here is the address for generating static pages */
.../* Other fields */
);

?>



After you extract the news address from the page, it will be OK ..

Supplement:

This URL is generated when the news is imported into the database. The specific process is as follows:
1. Enter the news content on the page and submit the form
2. Generate a URL by time or your custom format
3. concatenate SQL statements to write news content to the database. Note that the URL value must also be written to the database.
4. Obtain the template page content and generate a static page by URL

The URL field does not automatically generate content...

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.