discuzX3.2论坛帖子列表页调用帖子摘要实例

本文分享了在论坛中遇到的帖子摘要使用G变量无法获取的问题解决方法,包括如何正确引入函数库文件、获取帖子信息及附件等内容,以及模板调用代码的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

论坛帖子列表页调用帖子摘要使用G变量无法获取,网上找到的解决方案 与大家分享

//内容摘要
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

增加到 module/forum/forum_forumdisplay.php  line 810 
前一句是 $threadids[$threadindex] = $thread['tid'];

后一句是 $_G['forum_threadlist'][$threadindex] = $thread;

模板调用代码:
$thread['preview']
两个之间.  获取主题内容以及附件

转载于:https://www.cnblogs.com/pauper/p/4255318.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值