logo

JTBC5.0新闻内容页多模板自选实现方法

2025-02-19 点击 61

JTBC5新闻内容页多模板自选实现方法

1.添加数据字典
添加字符键字典
字典名:news_tpl
键 值(简体中文)
detail 默认模板
detail1 模板一
detail2 模板二
detail3 模板三
可以根据实际情况添加
其中键对应模块前端模板节点名,值对应模板选择时的显示名

2.添加字段

{"type":"select","text":"DIY\u6a21\u677f","required":false,"source":"news_tpl","sourceType":"dictionary"}

03.下拉选择框
字段名:tpl
名称:DIY模板
默认值:detail
数据字典:news_tpl

3.添加前端模板
节点名对应1中数据字典的键
模板detail默认存在不用添加

4.找到代码
文件news/common/diplomat/index.php中
找到

public function detail(Request $req, Response $res)
{


$renderer = new Renderer('index.$detail');


修改成

$tpl = strval($rs -> tpl);
$detail = !empty($tpl) ? $tpl : 'detail';
$renderer = new Renderer('index.'.$detail);
0%