Smarty 生成静态页
1、smarty配置文件:(直接繼承smarty類)
<?php
require('/libs/Smarty.class.php');
class SmartyMistake extends Smarty {
?function __construct() {
??parent::__construct();
??$this->template_dir = 'templates/';
??$this->compile_dir = 'templates_c/';
??$this->cache_dir = 'cache/';
??$this->cache_lifetime = 0;
??$this->caching = false;
??$this->left_delimiter = "{ff:";
??$this->right_delimiter = "/}";?
??$this->caching = true;? //生成靜態頁必須開啟,否則生成的靜態頁無動態內容
?}
}
2、模板處理頁面(index.php)
$vv = "說句心里話";
$smarty->assign("result",$vv);
$smarty->display('templates/index.tpl');
$content = $smarty->fetch('index.tpl', null, null, false);
$fp = fopen('index.html', 'w');
fwrite($fp, $content);
fclose($fp);
?
轉載于:https://blog.51cto.com/gesner/477902
總結
以上是生活随笔為你收集整理的Smarty 生成静态页的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【电影】美丽心灵的永恒阳光
- 下一篇: django的sqlite3的使用_2_