discuz 帖子列表页调用摘要代码
需要修改文件/source/module/forum/forum_forumdisplay.php 第812行左右找到:
$threadids[$threadindex] = $thread['tid'];
复制代码
在其下方增加
模板中调用代码:
$thread['preview']
复制代码
20161221更新
另一些直接写在模板的方法:
代码1:
代码2:
都有效,任选其一即可。
$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)}--> |
都有效,任选其一即可。
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
热门教程
discuz电脑版、手机版去除标题title中的PoweredbyDisc2018-12-27
Discuz 触屏手机版支持视频播放的方法2018-12-27
discuz手机版支持视频播放的修改方法2018-12-27
Discuz! 程序 X3.2、X3.3升级3.4教程2018-12-27
discuz X3以及X3.4论坛搬家完美详细教程2019-01-02
怎么开启手机版2018-12-25
去掉Discuz论坛底部的Powered 等版权信息2018-12-27
discuz! x3.4插件位置DZ论坛X3版本插件在哪个文件夹?2018-12-26
Mysql修改端口号后织梦dedecms的修改方法2018-12-27
Discuz!X3.2论坛实现全站HTTPS终极方法教程2018-12-28