Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[修改] Discuz! X2.5 论坛首页子版块另行竖排显示加发贴数教程

[复制链接]
dujun0618 发表于 2012-10-23 17:27:24 | 显示全部楼层 |阅读模式
论坛首页一般是显示后台设置的版块,现在2.5版块最多只能设置到子版块,而扩展设置里“本版块在首页显示下级子版块”选择是时,子版块是用逗号隔开文字串方式显示的而且没有当前子版块的发贴数。


现在要实现如图的效果:


不过这个效果的前提是:

论坛首页下级子版块横排要设置为0.


要修改二个模板文件。

一、/template/default/forum/discuz.htm文件,以下是实现版块显示代码部分,可以用<td class="fl_icn"进行查找,可以找到二个地方都有,选择后面一个。也就是代码行大的。
<td class="fl_icn" {if !empty($forum[extra][iconwidth]) && !empty($forum[icon])} style="width: {$forum[extra][iconwidth]}px;"{/if}>
        <!--{if $forum[icon]}-->
         $forum[icon]
        <!--{else}-->
         <a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}><img src="{IMGDIR}/forum{if $forum[folder]}_new{/if}.gif" alt="$forum[name]" /></a>
        <!--{/if}-->
       </td>
       <td>
        <h2><a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}{if $forum[extra][namecolor]} style="color: {$forum[extra][namecolor]};"{/if}>$forum[name]</a><!--{if $forum[todayposts] && !$forum['redirect']}--><em class="xw0 xi1" title="{lang forum_todayposts}"> ($forum[todayposts])</em><!--{/if}--></h2>
        <!--{if $forum[description]}--><p class="xg2">$forum[description]</p><!--{/if}-->
        <!--{if $forum['subforums']}--><p>{lang forum_subforums}: $forum['subforums']</p><!--{/if}-->
        <!--{if $forum['moderators']}--><p>{lang forum_moderators}: <span class="xi2">$forum[moderators]</span></p><!--{/if}-->
        <!--{hook/index_forum_extra $forum[fid]}-->
       </td>
       <td class="fl_i">
        <!--{if empty($forum[redirect])}--><span class="xi2"><!--{echo dnumber($forum[threads])}--></span><span class="xg1"> / <!--{echo dnumber($forum[posts])}--></span><!--{/if}-->
       </td>
       <td class="fl_by">
        <div>
        <!--{if $forum['permission'] == 1}-->
         {lang private_forum}
        <!--{else}-->
         <!--{if $forum['redirect']}-->
          <a href="$forumurl" class="xi2">{lang url_link}</a>
         <!--{elseif is_array($forum['lastpost'])}-->
          <a href="forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($forum[lastpost][subject], 30)}--></a> <cite>$forum[lastpost][dateline] <!--{if $forum['lastpost']['author']}-->$forum['lastpost']['author']<!--{else}-->$_G[setting][anonymoustext]<!--{/if}--></cite>
         <!--{else}-->
          {lang never}
         <!--{/if}-->
        <!--{/if}-->
        </div>
       </td>
      </tr>
      <!--{if $forum['subforums']}--><style>.subflist{border-top:#CCC dotted 1px; height:100%; width:100%}.subflist li{width:150px; height:30px; line-height:30px; text-align:center; overflow:hidden; float:left}</style><tr><td colspan="4"><div><ul class="subflist">$forum['subforums']</ul></div></td></tr><!--{/if}-->
      <tr class="fl_row">
      <!--{/if}-->
      <!--{/loop}-->
      $cat['endrows']
      </tr>

以上红色代码是默认的显示方式,可以删除,换成蓝色部分代码。注意要放在</tr><tr class="fl_row">之间。

还有个一定要注意,就是表格的样式要修改一下,不然IE下表格的列宽会自动变的。
修改方法:
找到以下代码,然后添加以下代码中红色部分代码,也就是style="table-layout:fixed"
<div id="category_$cat[fid]" class="bm_c" style="{echo $collapse['category_'.$cat[fid]]}">
<table cellspacing="0" cellpadding="0" class="fl_tb" style="table-layout:fixed">

二、/source/module/forum/forum_index.php文件

查找以下代码
$forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : ', ').'<a href="'.$forumurl.'" '.(!empty($forum['extra']['namecolor']) ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a>';

替换成以下代码
$forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : '').'<li><a href="'.$forumurl.'" '.(!empty($forum['extra']['namecolor']) ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a> <font color=red>('.$forum[todayposts].')</font></li>';


文章出处:http://www.cnit618.com/html/kyxt/discuz/2815.htm

duduopen 发表于 2012-10-23 18:19:55 | 显示全部楼层
效果看起来还不错
E侍弄 http://www.icoll.net
回复

使用道具 举报

 楼主| dujun0618 发表于 2012-10-23 20:57:33 | 显示全部楼层
看什么论坛吧有的用了效果更好
回复

使用道具 举报

1314学习网 发表于 2012-10-24 18:17:30 | 显示全部楼层
没想到还有前排
回复

使用道具 举报

20021110 发表于 2012-10-24 18:26:27 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

liqu12511 发表于 2012-10-24 19:08:27 | 显示全部楼层
楼主很强大

评分

1

查看全部评分

回复

使用道具 举报

 楼主| dujun0618 发表于 2012-10-25 21:32:40 | 显示全部楼层
只是适合用的网站不多,一般谁会把版块分那么细
回复

使用道具 举报

rmbgh 发表于 2013-5-11 13:09:43 | 显示全部楼层
什么鸟教程呀。。杂乱。。。。。。。。。。能不能简单点的真改吧。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-9-22 10:01 , Processed in 0.166990 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表