帖子列表页获取封面图片_discuz二次开发教程 找到文件 source/module/forum/forum_forumdisplay.php [/ol, 大于809行找到如下代码 if($thread['rushreply',) { $rushtids[$thread['tid',, = $thread['tid',; } [/ol, 在这段代码下面添加如下代码: $threada= C::t('forum_attachment')->fetch_all_by_id('tid', $thread['tid',, 'aid'); $threadaid = reset($threada); $threadpic = C::t('forum_attachment_n')->fetch_by_aid_uid($threadaid['tableid',, $threadaid['aid',, $thread['authorid',); $thread['pic', = $threadpic['attachment',; [/ol, 这样就可以在列表页模板中使用 $thread['pic', [/ol, 来加载一张封面图片,但是需要注意这样是加载最后一张插入的图片! 如果要改为第一张图片还需要修改另外的一个文件 找到文件 source/class/table/table_forum_announcement.php [/ol, 找到 $orderby = 'ORDER BY '.DB::order($orderby, 'DESC'); [/ol, 修改为: $orderby = 'ORDER BY '.DB::order($orderby, 'ASC'); [/ol, 好了这样就可在列表页,加载发帖时上传的第一张图片,做为封面来调用了!...
内容已隐藏,请关注公众号输入验证码查看
本帖支持关注公众号查看
【无套路 无套路 无套路 扫描二维码关注公众号发送【验证码】收到验证码 在上面输入点击提交查看即可显示隐藏内容】
|