本帖最后由 Yecent 于 2014-2-12 15:05 编辑
最近一直在摸索DZ模板制作修改,发现论坛帖子列表页调用帖子摘要使用G变量无法获取,有类似的插件,但是要钱,今天终于搞定了这个问题,分享一下给大家,效果见图:
增加到 module/forum/forum_forumdisplay.php line 810
前一句是 $threadids[$threadindex] = $thread['tid'];
- //内容摘要
- include_once libfile('function/post');
- include_once libfile('function/attachment');
- $thread['post'] = C::t('forum_post')->fetch_all_by_tid_position($thread['posttableid'],$thread['tid'],1);
- $thread['post'] = array_shift($thread['post']);
- $thread['preview'] = messagecutstr($thread['post']['message'], 200);
- $attachments = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['post']['tid'], 'pid', $thread['post']['pid']);
- $attachs = $imgattachs = array();
- foreach(C::t('forum_attachment')->fetch_all_by_id('pid', $thread['post']['pid'], 'aid') as $attach) {
- $attach = array_merge($attach, $attachments[$attach['aid']]);
- $attach['filenametitle'] = $attach['filename'];
- $attach['ext'] = fileext($attach['filename']);
- getattach_row($attach, $attachs, $imgattachs);
- }
- $thread['attachments'] = $imgattachs;
- //内容摘要END
复制代码 模板调用代码:
$thread['preview']
后一句是 $_G['forum_threadlist'][$threadindex] = $thread;
两个之间. 获取主题内容以及附件
应该有开源精神,别看到有钱了就联系我.
|