Manyou诚邀开发者加盟 | 常见问题
《站长》俱乐部官方群公布 城市联络员机会多多
立即免费下载 Discuz!7.0.0 正式版
安装升级指南 | 用户手册 | 新手建站学堂
基于.net架构的Discuz!NT2.6正式版发布
Comsenz公司2009年招贤纳士,期待您的加盟
Discuz!收费服务内容及价格
7月重庆、成都、西安三地社区运营实战特训速报名
Discuz!/UCHome 专用官方虚拟主机
牧场新服一起联运:豆浆机免费带回家
基于Discuz!的免费论坛空间5D6D
康盛创想《站长》俱乐部18城市互动之旅报名ing
返回列表 回复 发帖

[原创]主题分类以图片格式显示!(普通会员不能使用《公告》分类Hack)Dz5.0 Gbk

#############################################
插件名称:主题分类MEI化
适用版本:Dz5.0 GBK
作  者:badfox
修  改:
forumdisplay.php
viewthread.php
include\global.func.php
templates\default\post_editpost.htm
templates\default\post_newthread.htm

数据升级:无
安装难度:易
最后更新:2006/12/06
演  示:见楼下图片

功能说明:
将主题分类显示改为图片,可以文字与图片混合使用!


备  注:
本来以为不用更改模板,由于图片不能用下拉框显示,所以只有更改了发帖和编辑帖子的模板,将主题分类改为横排显示!



安装插件有风险,安装前注意备份文件!
#############################################

全新安装开始:
1、

forumdisplay.php

查找
  1. $thread['typeid'] = $thread['typeid'] && !empty($forum['threadtypes']['prefix']) && isset($forum['threadtypes']['types'][$thread['typeid']]) ?
  2.                 '['.$forum['threadtypes']['types'][$thread['typeid']].'] ' : '';
复制代码
替换为
  1. if($thread['typeid'] && !empty($forum['threadtypes']['prefix']) && isset($forum['threadtypes']['types'][$thread['typeid']])){
  2.         if(preg_match("/^[\w_.-]*$/", $forum['threadtypes']['types'][$thread['typeid']])){
  3.                 $thread['typeid']= '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['types'][$thread['typeid']].'.gif'.'" border="0" alt="" />' ;
  4.         }else{
  5.                 $thread['typeid']= '['.$forum['threadtypes']['types'][$thread['typeid']].'] ' ;

  6.         }
  7. }else{
  8.         $thread['typeid'] = '';
  9.         }
复制代码
查找
  1. $ppp = $forum['threadcaches'] ? $_DCACHE['settings']['postperpage'] : $ppp;
复制代码
上面添加
  1. if($forum['threadtypes'] && $forum['threadtypes']['listable']) {
  2.         if($forum['threadtypes']['flat']) {
  3.                 foreach($forum['threadtypes']['flat'] as $id => $name){

  4.                                         $forum['threadtypes']['flat'][$id] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['flat'][$id]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['flat'][$id].'.gif'.'" border="0" alt="" />' : $forum['threadtypes']['flat'][$id];
  5.                         }
  6.         }

  7.         if($forum['threadtypes']['selectbox']) {
  8.                 foreach($forum['threadtypes']['selectbox'] as $id => $name){

  9.                                         $forum['threadtypes']['selectbox'][$id] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['selectbox'][$id]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['selectbox'][$id].'.gif'.'" border="0" alt="" />' : $forum['threadtypes']['selectbox'][$id];

  10.                        
  11.                         }
  12.         }

  13. }
复制代码
2、

viewthread.php

查找
  1. if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
  2.         $thread['subject'] = ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">['.$forum['threadtypes']['types'][$thread['typeid']].']</a>' : '['.$forum['threadtypes']['types'][$thread['typeid']].']').' '.$thread['subject'];
  3. }
复制代码
替换为
  1. if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
  2.         $forum['threadtypes']['types'][$thread['typeid']] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['types'][$thread['typeid']]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['types'][$thread['typeid']].'.gif'.'" border="0" alt="" />' : '['.$forum['threadtypes']['types'][$thread['typeid']].'] ';
  3.         $thread['subject'] = ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">'.$forum['threadtypes']['types'][$thread['typeid']].'</a>' : $forum['threadtypes']['types'][$thread['typeid']]).' '.$thread['subject'];

  4. }
复制代码
3、
include\global.func.php
查找
  1. function typeselect($curtypeid = 0) {
  2.         if($threadtypes = $GLOBALS['forum']['threadtypes']) {
  3.                 $html = '<select name="typeid"><option value="0">&nbsp;</option>';
  4.                 foreach($threadtypes['types'] as $typeid => $name) {
  5.                         $html .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>';
  6.                 }
  7.                 $html .= '</select>';
  8.                 return $html;
  9.         } else {
  10.                 return '';
  11.         }
  12. }
复制代码
替换为
  1. function typeselect($curtypeid = 0) {
  2.         $i = 1;
  3.         $br = '';
  4.         $typemark = '';
  5.         if($threadtypes = $GLOBALS['forum']['threadtypes']) {
  6.                 $html[1] = '';
  7.                 $html[2] = '<select name="typeid"><option value="0">&nbsp;</option>';
  8.                 foreach($threadtypes['types'] as $typeid => $name) {
  9.                 if(preg_match("/^[\w_.-]*$/", $name)) {
  10.                                         if($i==8) {
  11.                                                 $br= '<br />';
  12.                                                 $i = 0;
  13.                                         }  else {
  14.                                                 $br= '';
  15.                                         }
  16.                                         $i++;
  17.                                         $html[1] .= '<input class="radio" type="radio" name="typeid" value="'.$typeid.'"'.($curtypeid == $typeid ? 'selected' : '').'>'.'<img src="'.IMGDIR.'/types/'.$name.'.gif'.'" border="0" alt="" />&nbsp;&nbsp;'.$br;
  18.                                         $typemark = '1';
  19.                                 }else{
  20.                                         if($i==8) {
  21.                                                 $br= '<br />';
  22.                                                 $i = 0;
  23.                                         }  else {
  24.                                                 $br= '';
  25.                                         }
  26.                                         $i++;
  27.                                         $html[1] .= '<input class="radio" type="radio" name="typeid" value="'.$typeid.'"'.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'&nbsp;&nbsp;'.$br;

  28.                                         $html[2] .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>';
  29.                                 }
  30.                 }
  31.                 $html[2] .= '</select>';
  32.                 if($typemark) {
  33.                         $html[2] = '';
  34.                 }else {
  35.                         $html[1] = '';
  36.                 }
  37.                 return $html;
  38.         } else {
  39.                 return '';
  40.         }
  41. }
复制代码
4、

templates\default\post_newthread.htm

查找
  1. <tr>
  2. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  3. <td class="altbg2">$typeselect <input type="text" name="subject" id="subject" size="45" value="$subject" tabindex="3"></td>
  4. </tr>
复制代码
替换为
  1. <!--{if $typeselect[1]}-->
  2. <tr>
  3. <td class="altbg1" width="20%"><span class="bold">主题分类</span></td>
  4. <td class="altbg2"> $typeselect[1]</td>
  5. </tr>
  6. <!--{/if}-->
  7. <tr>
  8. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  9. <td class="altbg2"> $typeselect[2] <input type="text" name="subject" id="subject" size="45" value="$subject" tabindex="3"></td>
  10. </tr>
复制代码
5、
templates\default\post_editpost.htm

查找
  1. <tr>
  2. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  3. <td class="altbg2">
  4. <!--{if $isfirstpost}-->$typeselect<!--{/if}-->
复制代码
替换为
  1. <!--{if $isfirstpost}-->
  2. <!--{if $typeselect[1]}-->
  3. <tr>
  4. <td class="altbg1" width="20%"><span class="bold">主题分类</span></td>
  5. <td class="altbg2"> $typeselect[1]</td>
  6. </tr>
  7. <!--{/if}-->
  8. <!--{/if}-->
  9. <tr>
  10. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  11. <td class="altbg2">
  12. <!--{if $isfirstpost}-->$typeselect[2]<!--{/if}-->
复制代码
6、
将主题分类的图片上传到images\default\types目录下,即主题分类图片的目录是images\default\types

附件中提供部分分类图片,做的很粗糙,仅供测试!

7、
进后台,添加主题分类,将主题分类图片名称添加为主题分类,注意图片名称不能为中文和特殊字符,建议只用字母和数字!
编辑论坛,设置显示主题分类!

注意,图片为gif格式。
也可以汉字的主题分类,混合使用,互不影响!
如果全部为汉字的主题分类,则编辑帖子和发新帖界面主题分类变为下拉框显示!


详见楼下图片!

全新安装结束。


#############################################
有人问如何控制普通会员不能使用“公告”分类,我想到一个办法能实现!

添加WAN主题分类后,查到“公告”分类的id,假设为'1'
则打开
include\newthread.inc.php

查找

        if(!$typeid && $forum['threadtypes']['required']) {
                showmessage('post_type_isnull');
        }

下面添加

        if($typeid == '1' && !$forum['ismoderator']) {
                showmessage('您不属于管理组,不能使用此主题分类!');
        }


#############################################

[ 本帖最后由 badfox 于 2006-12-7 09:17 编辑 ]

主题分类.rar (5.73 KB)

Discuz! Support Team Forum:   Discuz!系列程序的独立第三方团队
论坛注册:http://www.discuzsupport.net/register.php?fromuid=139
(我的宣传地址,给加点宣传度吧,拜托!)
沙发...........

[ 本帖最后由 badfox 于 2006-12-6 21:25 编辑 ]
后台.jpg
发新帖.jpg
帖子列表.jpg
帖子编辑.jpg
帖子浏览.jpg
限制分类.jpg
Discuz! Support Team Forum:   Discuz!系列程序的独立第三方团队
论坛注册:http://www.discuzsupport.net/register.php?fromuid=139
(我的宣传地址,给加点宣传度吧,拜托!)
板凳........................
Discuz! Support Team Forum:   Discuz!系列程序的独立第三方团队
论坛注册:http://www.discuzsupport.net/register.php?fromuid=139
(我的宣传地址,给加点宣传度吧,拜托!)
空间演示:  viki生活馆
双线空间,1G300元 送100M MYSQL数据库,试用7天30天内无条件退款
官网:速度吧 客服 QQ:52033446
看上去好象不错啊 呵呵

友情连接



新贵E族
--[http://www.sex.com]----------------------jianquan
自己顶...............
Discuz! Support Team Forum:   Discuz!系列程序的独立第三方团队
论坛注册:http://www.discuzsupport.net/register.php?fromuid=139
(我的宣传地址,给加点宣传度吧,拜托!)
:)
免费资源推荐专 家http://www.hotgsu.com
用我的真诚推荐免费资源换你的一个IP.
  
不错哦                              .
图片美化起来效果一定很好
DISCUZ 7.0.0终于要来了!!!
返回列表