首先,您需要编辑文件 /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']
第一种方法:
<!--{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);}-->
<!--{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论坛就可以成功实现内容摘要功能了。这不仅提升了用户体验,也使论坛更加美观和实用。请确保在修改核心文件前备份原始文件,以防万一出现问题可以迅速恢复。
希望本文对您有所帮助!如果您还有其他问题或需要进一步的帮助,请随时访问相关论坛或社区寻求支持。