很多站长希望在DIY的时候调用主题标签TAG,Discuz!默认是不支持调用TAG的,本文介绍如何修改DIY源码实现我们所需要的功能:
修改文件:source/class/forum/block_thread.PHP
搜索
<div><font size="4">
</font></div><div><font size="4">'todayposts' => array('name' => lang('blockclass', 'blockclass_thread_field_todayposts'), 'formtype' => 'text', 'datatype' => 'int'), </font></div>
在下方添加
<div><font size="4">
</font></div><div><font size="4">'keywords' => array('name' => "主题标签", 'formtype' => 'text', 'datatype' => 'string'), </font></div>
再搜索
<div><font size="4">if($style['getsummary']) { </font></div><div><font size="4"> $threadtids[$data['posttableid']][] = $data['tid']; </font></div><div><font size="4">} </font></div>
再下方添加
<div><font size="4">$tags = DB::result_first("select tags from ".DB::table("forum_post")." where first=1 and tid=".$data['tid']); </font></div><div><font size="4">$tags = explode("\t",$tags); </font></div><div><font size="4">$keywords = ''; </font></div><div><font size="4">foreach($tags as $tag){ </font></div><div><font size="4"> $array = explode(",",$tag); </font></div><div><font size="4"> if($array[1]) </font></div><div><font size="4"> $keywords .= '<a title="'.$array[1].'" href="misc.php?mod=tag&id='.$array[0].'" target="_blank">'.$array[1].'</a>,'; </font></div><div><font size="4">} </font></div><div><font size="4">$keywords = substr($keywords,0,-1); </font></div>
这里添加的样式是带有链接的,如果不加链接,可以改成:
<div><font size="4">
</font></div><div><font size="4">$tags = DB::result_first("select tags from ".DB::table("forum_post")." where first=1 and tid=".$data['tid']); </font></div><div><font size="4">$tags = explode("\t",$tags); </font></div><div><font size="4">$keywords = ''; </font></div><div><font size="4">foreach($tags as $tag){ </font></div><div><font size="4"> $array = explode(",",$tag); </font></div><div><font size="4"> if($array[1]) </font></div><div><font size="4"> $keywords .= $array[1].','; </font></div><div><font size="4">} </font></div><div><font size="4">$keywords = substr($keywords,0,-1); </font></div>
再搜索
<div><font size="4">
</font></div><div><font size="4">'fields' => array( </font></div>
在下方添加
<font size="4">'keywords' => $keywords, </font>
后台,工具,更新DIY模块缓存,然后正常使用帖子模块即可发现可以使用{keywords}调用主题标签了
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!