来源: 本站版本: (PHP)JTBC3.0
本例子以新闻模块为例子
1.数据表添加字段
手动添加字段参考
`n_video` varchar(255) DEFAULT 'NULL'
COMMENT '{"fieldType":"upfile","fieldHasTips":"auto","uploadStatusAutoUpdate":"true"}',
或运行以下sql语句
ALTER TABLE `JTBC_news` ADD `n_video` VARCHAR(255) NULL DEFAULT NULL COMMENT '{"fieldType":"upfile","fieldHasTips":"auto","uploadStatusAutoUpdate":"true"}' AFTER `n_att`;
2.添加字段对应的语言
/common/language/config.jtbc
<item>
<name><![CDATA[video]]></name>
<zh-cn><![CDATA[上传视频]]></zh-cn>
</item>
3.修改模块前台代码
/news/common/incfiles/index.inc.php
public static function moduleList()
找到代码块
$rsAry = $pagi -> getDataAry($page, $pagesize);
$variable = array_merge($variable, $pagi -> getVars());
$tmpstr = tpl::takeAndAssign('index.list', $rsAry, $variable);
修改成
$rsAry = $pagi -> getDataAry($page, $pagesize);
$datas = array();
$rsArys = array();
for($i=0;$i<count($rsAry);$i++){
foreach($rsAry[$i] as $k => $v){
$datas[$k]= $v;
if(!empty($datas[$dal ->prefix.'video'])) $datas[$dal ->prefix.'ico'] = '<img src="/common/assets/themes/default/video.png" />';
else $datas[$dal ->prefix.'ico'] = '';
}
$rsArys[$i] = $datas;
}
$variable = array_merge($variable, $pagi -> getVars());
$tmpstr = tpl::takeAndAssign('index.list', $rsArys, $variable);
注意最后一行$rsArys这个加了s.
img 这里可以写死图片宽度和高度,或者直接给个class,然后css里控制
4.上传图标文件
/common/assets/themes/default/video.png
5.模板添加
{$topic} {$=encodeText(#RS_ico)}
调用必须要用encodeText包含,否则会显示html实体代码
6.结束
技术支持QQ:925474725