First have to populate the template with content that needs to be static
The code is as follows: #eg. This is the static homepage function Staticindex () { $newslist = $article->getarticles (null,54, ' DESC ', 1,6,false,1,2, ", 0,0,1); if ($newslist) { foreach ($newslist as $k => $v) { $newslist [$k] [' Title_ All '] = $v [' title ']; $newslist [$k] [' title '] = Cutstr ($v [' title '],36, ' ... '); } $smarty->assign (' newslist ', $newslist);   $content = '; $content = $smarty->fetch (' index.html ', true);//This is the function of the smarty generated static page $static _name = root_path. ' Index.html '; This is to generate a static page the current path file fopen ($static _name, ' a ');//Open this file @file_put_contents ($static _name, $content);/finally write return true; //Static list page, different by category by row static function staticcontent () {///required static words of the number $ids = array ();/Get all content $ids = $this->getlistids ();//This method gets all the content, the following red Word part corresponds to its method foreach ($ids as $k => $value) { //echo $ value[' catid ']; if (!file_exists (root_path. ' demo/')) {//Judge root directoryFace has no this folder, if not then create demo this folder mkdir (root_path. ' demo/'); } if (!file_exists (root_path. ' demo/'. $value [' catid ']) {//Determine if there is a corresponding category folder under this folder mkdir (root_path. ' demo/'. $value [' catid ']); } $html _content = $this->getdemocontent ($value [' demoid ']); $static _name = root_path. ' demo/'. $value [' catid ']. /'. $value [' demoid ']. HTML '; fopen ($static _name, ' a '); @file_put_contents ($static _name, $html _content); } return true; } //Take out the page ID function that needs to be statically getlistids () { $sql = "Select * from {$this->tablepre}demo o Rder by demoid ASC "; $rs = $this->db->getall ($sql); if ($rs) { return $rs }else{ return false; }} &nbs P Content Single page static function Getdemocontent ($id) { global $smarty, $view _templAtes, $admin _templates; loadmodel (' demo '); $demo = new demo (); $content = '; $smarty->template_dir = Root_path $view _templates; $getMobanOne = $this->getmobandetail ($id); $mobandetail = $demo->mobanlist ($id); foreach ($mobandetail as $k => $v) { $smarty->assign ($k, $v); &NB Sp &NBSP} $this->catid = $getMobanOne [' catid ']; $smarty->assign (' Pre_title ', $mobandetail [' membername ']); $smarty->assign (' Mobandetail ', $mobandetail); $content = $smarty->fetch (' demo_show.html ', true); $smarty->template_dir = Root_path $view _templates; return $content; used to generate static page every time to execute PHP file, and then to generate, now I write this is controlled by people, want to generate on the generation, very convenient, hope to bring convenience to everyone, I wish you a happy work.