最近论坛遇到个问题,Discuz tag标签出了问题,编辑一次就添加一个标签,如下图:
<ignore_js_op>
删都删不掉,看着真TM不爽,于是,想到了解决办法,如下:
Discuz帖子下方的tag标签重复显示,表现为相同的tag标签多次显示,帖子编辑次数越多,tag重复的次数越多。
Discuz!官方直到Discuz X3.2也没有解决tag重复的问题。
要解决Discuz标签重复,可以通过修改source\module\forum\forum_viewthread.php来实现。
用notepad++之类的文本编辑软件打开forum_viewthread.php,搜索以下内容
|
001
|
$tagarray_all = explode("\t", $post[‘tags‘]); |
将该行下方的以下代码
|
001
002
003
004
005
006
007
008
009
|
if($tagarray_all) { foreach($tagarray_all as $var) { if($var) { $tag = explode(‘,‘, $var); $posttag_array[] = $tag; $tagnames[] = $tag[1]; } }} |
修改为
|
001
002
003
004
005
006
007
008
009
010
011
012
013
014
|
$tagIds=array();if($tagarray_all) { foreach($tagarray_all as $var) { if($var) { $tag = explode(‘,‘, $var); if(in_array($tag[0], $tagIds, true)){ continue; } $tagIds[]=$tag[0]; $posttag_array[] = $tag; $tagnames[] = $tag[1]; } }} |
原文:http://www.cnblogs.com/yaogua/p/6486622.html