内容详情中(show.html) 模板中调用方法是:
{loop $字段名 $i $c}
序号: {$i}
附件ID:{$c.file}
标题:{$c.title}<br>
描述:{$c.description}<br>
文件原始地址:{dr_get_file($c.file)}
文件的下载地址:{dr_down_file($c.file)}
图片缩略图:{dr_thumb($c.file, 200, 200)}
图片缩略图带水印:{dr_thumb($c.file, 200, 200, 1)}
{if $key_t==0}第一条{/if}
{/loop}注意:
1、[字段名]需要换成你定义的具体字段英文名称
2、如果在list循环中调用,需要把[字段名]改成[$t.字段名]
示例:
1、循环列表中调用多文件字段中第1张图片
{dr_thumb($t['字段名'][0]['file'],240,240)}2、调用附件扩展名
{loop $字段名 $i $c}
{php $data = \Phpcmf\Service::C()->get_attachment($c.file);}
扩展名:{$data.fileext}
判断扩展名:
{if $data.fileext=='pdf'}
这是pdf文件
{else if $data.fileext=='zip'}
这是zip文件
{else}
这是其它文件
{/if}
{/loop}手动格式化
{php $字段名 = dr_get_files($字段名);}示例
1、判断文件数量,以循环列表为例
{if dr_count($t.字段名)>=3}
多文件数量大于等于3个
{else if dr_count($t.字段名)>=1}
多文件数量大于等于1个
{else if dr_count($t.字段名)==0}
0个
{/if}2、判断扩展名
视频附件判断是不是mp4文件名,如果是第三方平台视频链接就采用iframe引用
{loop $video $i $c}
{php $data = \Phpcmf\Service::C()->get_attachment($c.file);}
<li class="col-md-6">
{if $data.fileext=='mp4'}
<video width="100%" height="300" controls>
<source src="{dr_get_file($c.file)}" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
您的浏览器不支持Video标签。
</video>
{else}
<iframe class="iframe-video" width="100%" height="300" frameborder="0" src="{dr_get_file($c.file)}&autoplay=true" allowFullScreen="true"></iframe>
{/if}
</li>
{/loop}调用附件信息详细文档
https://www.diyuncms.com/help/show/1023.html



