Home  >  Article  >  Backend Development  >  discuz!怎样实现主题列表页显示帖子正文摘要?非预览功能。

discuz!怎样实现主题列表页显示帖子正文摘要?非预览功能。

WBOY
WBOYOriginal
2016-06-23 13:50:491315browse

如下图那样显示对应的主题的正文前200字。但对应的模版文件里好像没有“内容”的变量啊,求教


回复讨论(解决方案)


重点看红色区域的代码,应该会对你有用,这个是直接获得该文章的内容,


重点看红色区域的代码,应该会对你有用,这个是直接获得该文章的内容,



这段代码在那个模版文件里的?

不建议在模版文件中执行查询
打开后台文件\source\module\forum\forum_forumdisplay.php

//搜索foreach($threadlist as $thread) {//在其上面添加foreach($threadlist as $v){	$tids[]=$v['tid'];}$strtids=join(',',$tids);$msginfos=DB::fetch_all("SELECT tid,message FROM %t WHERE tid IN($strtids)",array('forum_post'));if(!function_exists('messagecutstr')){	require_once libfile('function/post');}foreach($msginfos as $v){	$cutmsginfos[$v['tid']]=messagecutstr($v['message'],200);}//在其下面添加$thread['cutmsg']=$cutmsginfos[$thread['tid']];

前台用$thread['cutmsg']就可以获取
打开模版文件\template\default\forum\forumdisplay_list.htm
<!--230行左右,</tbody>上面添加--><tr>									<td colspan="6">$thread['cutmsg']</td>								</tr>


样子如上图所示,样式自己调


不建议在模版文件中执行查询
打开后台文件\source\module\forum\forum_forumdisplay.php
谢谢你的答案,很耐心很详细。衷心感谢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn