花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來(lái)到素材無(wú)憂網(wǎng),按 + 收藏我們
登錄 注冊(cè) 退出 找回密碼

discuz 帖子列表頁(yè)調(diào)用摘要代碼

時(shí)間: 2019-05-24 11:57 閱讀: 作者:素材無(wú)憂網(wǎng)

需要修改文件/source/module/forum/forum_forumdisplay.php 第812行左右找到:
$threadids[$threadindex] = $thread['tid'];
復(fù)制代碼
在其下方增加
//內(nèi)容摘要
         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;
        //內(nèi)容摘要END


模板中調(diào)用代碼:
$thread['preview']
復(fù)制代碼

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)}-->

都有效,任選其一即可。

版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請(qǐng)注明: discuz 帖子列表頁(yè)調(diào)用摘要代碼

標(biāo)簽:  
相關(guān)文章
模板推薦