关于thinkphp5模板支持include引入动态模板方法
2023-03-29 23:03:03
1113
{{single.collect_count}}

使用thinkphp5在模板页面想动态引入不同的模板,但是不能被正常解析,看了网上的几种方法,只能去修改原始方法文件了,具体如下:

{include file=”$param/head”}

<include file="$template1" />

修改文件

thinkphp\library\think\Template.php文件下的parseInclude方法

在这里插入图片描述
添加的代码

if(isset($array['append']) &&$array['append']){if(0===strpos($array['append'],'$')){$array['append'] = $this->get(substr($array['append'],1));}$file = $array['append'].$array['file'];unset($array['append']);}else{$file= $array['file'];}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}