ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# fileinfo 获取附件信息(文件下载) ## fileinfo 获取附件信息 用于获取附件详细信息,同时支持文件下载,支持图片、图片(多)、文件上传、文件上传(多)组件。 ## 参数 参数名称可选值默认值是否必填说明id-$item-指定循环里的变量名,例如id='obj',模板调用如:{$item.title} 变成 {$obj.title}name--是传入支持的组件字段变量field---统计文件下载次数字段aid---文档ID,在内容页(详情页)无需填写model---模型ID,与aid同时使用,在内容页(详情页)无需填写cache-3600秒-缓存时间,默认3600秒,对非分页数据有效## 参数说明 `name` 属性,支持数组、字符串变量。例如:在模型增加files字段,类型是多文件上传。 ``` <pre class="calibre16">``` <span class="token5">// 假设你附件字段iles,$Info是详情页都有的变量,是当前文档的信息</span> <span class="token1">{</span>hkcms<span class="token1">:</span>fileinfo name<span class="token">=</span><span class="token4">"$Info.files"</span> id<span class="token">=</span><span class="token4">"vo"</span><span class="token1">}</span> 附件标题:<span class="token1">{</span>$vo<span class="token1">.</span>title<span class="token1">}</span> 下载地址:<span class="token1">{</span>$vo<span class="token1">.</span>url<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>fileinfo<span class="token1">}</span> ``` ``` `field` 统计文件下载次数的字段,该属性非必填项,例如:在模型字段新增`download`字段,用于记录该文档所有文件下载次数。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>fileinfo name<span class="token">=</span><span class="token4">"$Info.files"</span> id<span class="token">=</span><span class="token4">"vo"</span> field<span class="token">=</span><span class="token4">"download"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$vo.url}"</span><span class="token">></span>本地下载<span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>fileinfo<span class="token1">}</span> ``` ``` `aid与model` 文档ID与模型id属性,在指定统计`field`属性时,通常在内容页无需填写,如果用在其他地方这里需要填写文档ID与模型ID,支持变量。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>fileinfo name<span class="token">=</span><span class="token4">"$Info.files"</span> id<span class="token">=</span><span class="token4">"vo"</span> field<span class="token">=</span><span class="token4">"download"</span> aid<span class="token">=</span><span class="token4">"1"</span> model<span class="token">=</span><span class="token4">"2"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$vo.url}"</span><span class="token">></span><span class="token1">{</span>$vo<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>fileinfo<span class="token1">}</span> ``` ``` - 视频列表 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>fileinfo name<span class="token">=</span><span class="token4">"$Info.video"</span> id<span class="token">=</span><span class="token4">"video"</span> field<span class="token">=</span><span class="token4">"views"</span><span class="token1">}</span> <span class="token"><</span>video controls style<span class="token">=</span><span class="token4">"width: 200px"</span> preload<span class="token">=</span><span class="token4">"auto"</span><span class="token">></span> <span class="token"><</span>source src<span class="token">=</span><span class="token4">"{$video.path}"</span> type<span class="token">=</span><span class="token4">"video/mp4"</span><span class="token">></span> <span class="token"><</span><span class="token">/</span>video<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>fileinfo<span class="token1">}</span> ``` ``` - 图片列表 ``` <pre class="calibre20">``` <span class="token1">{</span>hkcms<span class="token1">:</span>fileinfo name<span class="token">=</span><span class="token4">"$Info.thumb"</span> id<span class="token">=</span><span class="token4">"vo"</span> field<span class="token">=</span><span class="token4">"views"</span><span class="token1">}</span> <span class="token"><</span>img src<span class="token">=</span><span class="token4">"{$vo.path}"</span> alt<span class="token">=</span><span class="token4">"{$vo.title}"</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>fileinfo<span class="token1">}</span> ``` ```