J5_05产品新闻详情页
1、头尾模板调用代码
{$=$take('global.communal.header')}
{$=$take('global.communal.footer')}
{$title}标题
{$time}时间
{$=$take('index.title', 'lng')}模块名称
{$=$htmlEncode(#summary, 2)}文章摘要
{$=$htmlEncode(#content, 0)}文章内容
{$=$htmlEncode(mb_substr(strip_tags(#content), 0, 100))}内容截取
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{$count}点击量
jtbc/Public/news/common/diplomat/index.php文件,detail节点
$rs = $model -> get();这句前加
$model -> pocket -> count = ['increase' => 1];
$model -> save();
模块管理news数据库加字段count,8数值输入器,默认值0,如已加文章,需编辑文章count字段输入1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{$=$render('global.render.product-list', $fetch(['genre' => 'universal/category', 'where' => ['genre' => 'product', 'father_id' => 0]]))}调用产品分类
{$=$render('global.render.product-news-a', $fetch(['genre' => 'news', 'limit' => 6]))}调用news文章列表
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
调用上下页
{$=$render('global.render.up', $fetch(['where' => ['id' => ['unEqual' => #id], 'time' => ['min' => #time]], 'orderBy' => [['time', 'asc']], 'limit' => 1]))}
{$=$render('global.render.down', $fetch(['where' => ['id' => ['unEqual' => #id], 'time' => ['max' => #time]], 'orderBy' => [['time', 'desc']], 'limit' => 1]))}
其中updown节点内容:{@}<li>上一篇:<a href="?type=detail&id={$id}">{$title}</a></li>{@}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
调用节点产品文章链接 图片地址 标题
{@}<a href="product/?type=detail&id={$id}">
<img src="{$=$htmlEncode($getValueFromJSON(#image, 'fileurl'))}" alt="{$title}" />
</a>{@}
分类页面 显示分类名称
在\universal\common\template\render.jtbc 新建节点categorytitle
{$title}
详情模板调用
{$=$render('universal:render.categorytitle', $fetch(['genre' => 'universal/category', 'where' => ['genre' => '{$>this.genre}', 'id' => {$category}]]))}
相关文章
{$=$render('global.render.blog-list', $fetch(['where' => ['id' => ['unEqual' => #id], 'category' => #category], 'orderBy' => [['rand()']], 'limit' => 10]))}
节点 [ blog-list ]代码如下:
<li><a href="{$=$getActualRoute('blog')}/detail-{$id}.html">{$title}</a></li>
调用联系方式节点模板内容{$=$take('global.render.contactus')}
在详情页中调用图片字段,只需要这样写
<div class="image"><img src="{$=$htmlEncode($getValueFromJSON(#image, 'fileurl'))}" /></div>
调用附件图片列表
{$=$render('index.att',$jsonDecode(#attachment))}
其中att节点代码:
{@}<div class="image"><p type="image"><img src="{$filepath}" alt="{$filename}" /></p></div>{@}
如果只是调用附件的第一条数据,则可以直接这样写
{$=$htmlEncode($getValueFromJSON(#attachment, '0->filepath'))}
{$=$htmlEncode($getValueFromJSON(#attachment, '1->filename'))}第2条附件地址
调用附件所属文章标题{$=$render('global.render.categorytitle', $fetch(['genre' => 'zhiwu', 'where' => ['id' => intval($req -> get('id')) ]]))}
详情页面调用分类图片
在\universal\common\template\render.jtbc 新建categoryimage节点
{$=$htmlEncode($getValueFromJSON(#image, 'fileurl'))}
前端模板
<img src="{$=$render('global.render.categoryimage', $fetch(['genre' => 'universal/category', 'where' => ['genre' => '{$>this.genre}', 'id' => {$category}]]))}" />
图片集
增加节点value-img2
<li><img src="{$fileurl}" /></li>
详情页模板
{$=$render('universal:render.value-img2', json_decode(#attachment, true))}
{$=$render('universal:render.value-img2', json_decode(#attachment, true)?? [])}
{$=$render('global.render.value-img2', json_decode(#attachment, true)?? [])}
下面这一句 表示 调用可以为空