最新最全的移动资源,海量教程攻略!

网站首页 > 技术支持 > discuz > discuz使用教程 > discuz最近 帖子列表页调用摘要代码

discuz最近 帖子列表页调用摘要代码

作者: 资源猫 时间: 2020-03-03 17:45:34 人气: 7

需要修改文件/source/module/forum/forum_forumdisplay.php 第812行左右找到:
$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']
复制代码
20161221更新
另一些直接写在模板的方法:
代码1:
!--{eval require_once(DISCUZ_ROOT. ./source/function/function_post.php }-- !--{echo messagecutstr(DB::result_first('SELECT `message` FROM '.DB::table('forum_post').' WHERE `tid` ='.$thread[tid].' AND `first` =1'),300);}--
复制代码
代码2:
!--{eval $threadlist_message = DB::result(DB::query( SELECT message FROM .DB::table('forum_post'). WHERE `tid` = $thread[tid] AND `first` =1 ));}--
!--{echo cutstr($threadlist_message,300)}--
复制代码
都有效,任选其一即可。

感谢访问资源猫吧,本站所有资源均来自互联网或用户分享,如您发现本站存在侵权或违规内容,请来邮件告知我们! 资源分享/侵权下架/商务合作联系邮箱:qiazou77ziyuan@126.com