利用\think\template\driver\File.php文件整合buildHtml
1.在controller.php創建方法如下
/**
- 創建靜態頁面
- @access protected
- @htmlfile 生成的靜態文件名稱
- @htmlpath 生成的靜態文件路徑
- @param string $templateFile 指定要調用的模板文件
- 默認爲空 由系統自動定位模板文件
- @return string
*/
protected function buildHtml($htmlfile = ‘’, $htmlpath = ‘’, $templateFile = ‘’)
{
$content = templateFile);
htmlpath) ? $htmlpath : ‘./appTemplate/’;
$htmlfile = $htmlpath . $htmlfile . ‘.’.config(‘url_html_suffix’);
$File = new \think\template\driver\File();
htmlfile, $content);
return $content;
}
2.需要用到的地方直接調用
id,APP_PATH.‘app/view/content/’,APP_PATH.‘app/tpl/activity.html’);
$this->buildHtml(‘index’,APP_PATH.’…/resource/index/’,‘index’);