tp5.1如何生成html?
thinkphp吧
全部回复
仅看楼主
level 1
啊琦 楼主
fetch是可以正常显示页面的,但是file->write总是提示缓存写入失败,runtime文件夹权限改了的,这咋整…最终目的就是想根据模板生成静态的html,望看到的大佬指点一二,谢过。
2021年05月26日 08点05分 1
level 1
啊琦 楼主
怎么@ 吧主大人…自己手动顶一贴
2021年05月26日 08点05分 2
level 1
啊琦 楼主
再手动顶一贴…
2021年05月27日 01点05分 3
level 1
啊琦 楼主
最后顶一贴吧,都没人
2021年05月28日 01点05分 4
level 1
啊琦 楼主
没人来我自己发吧…有点**,怪不得没人回。
controller下加上tp5的fetch
protected function fetchh($template = '', $vars = []){
return $this->view->fetch($template, $vars);
}
然后页面调用就行
public function startBuild($htmlfile = 'index',$htmlpath = './html/',$templet = 'index@index/index',$action = 'index/index/index'){ //index@index/index
action($action);
$info = $this->buildHtml($htmlfile,$htmlpath,$templet);
echo $info;
}
public function buildHtml($htmlfile='index',$htmlpath='./html/',$templateFile = 'index@index/index') {
$content = $this->fetchh($templateFile);
$htmlfile = $htmlpath.$htmlfile.'.html';
$File = new \think\template\driver\File();
$File->write($htmlfile,$content);
return $content;
}
2021年05月31日 10点05分 5
1