文档或下载模块附件(pdf、word、xls文档)预览代码分享,这段代码网上有,下面的是我在迅睿里调试好的,复制粘贴可用。
1.首先是引入相应的js文件:
[xss_clean][xss_clean]
这个jquery.media.js大家可以百度下载,这里就不贴地址了。
2.在模块类添加附件字段(file字段,字段名fjdown),附件后显示[预览]的代码为:
{php $data = \Phpcmf\Service::C()->get_attachment($fjdown);}
{if $fjdown}->点击下载:{$data.filename}({dr_format_file_size($data.filesize)},{$data.fileext}文件) [预览]{else}{/if}
这种显示可用于列表(list)和显示页面(show)。
3.pdf文档可在页面显示预览,代码如下:
[xss_clean]
$('#handout_wrap_inner').media({
width: '100%',
height: '800',
autoplay: true,
src:'uploadfile/{$data.attachment}',
});
[xss_clean]
这种显示用于显示页面(show)。