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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

Discuz! X2群组推荐到论坛版块的横排显示方法(可自由设置横排显示个数)

[复制链接]
otherbank 发表于 2011-10-28 12:15:22 | 显示全部楼层 |阅读模式
本帖最后由 otherbank 于 2011-10-28 12:29 编辑

群组推荐到论坛板块后无法横排显示,后台没有这个设置功能,默认一排只能显示一个群组,与上面横排显示的论坛板块不是很协调,如下图:

怎样才能横排显示推荐的群组呢,如下图:



这里讲一个方法,两步可以实现,需要修改程序和模板:
一、找到程序文件的"\source\module\forum\forum_forumdisplay.php"的305-312行:
  1. if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
  2.         $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
  3. }
  4. $recommendgroups = array();
  5. if($_G['forum']['status'] != 3 && $_G['setting']['groupstatus']) {
  6.         loadcache('forumrecommend');
  7.         $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
  8. }
复制代码
修改为:
  1. if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
  2.         $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
  3. }
  4. $recommendgroups = array();
  5. if($_G['forum']['status'] != 3 && $_G['setting']['groupstatus']) {
  6.         loadcache('forumrecommend');
  7.         $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
  8. }

  9. $_G['groups']['forumcolumns'] = 3 ;
  10. $_G['groups']['forumcolwidth'] = (floor(100 / $_G['groups']['forumcolumns']) - 0.1).'%';
  11. $_G['groups']['endrows'] = '';
  12. if($colspan = count($recommendgroups) % $_G['groups']['forumcolumns']) {
  13.         while(($_G['groups']['forumcolumns'] - $colspan) > 0) {
  14.                 $_G['groups']['endrows'] .= '<td> </td>';
  15.                 $colspan ++;
  16.         }
  17.         $_G['groups']['endrows'] .= '</tr>';
  18. }
复制代码
$_G['groups']['forumcolumns'] = 3 ;”的值,既是横排显示的个数,可自由修改。

二、找到模板文件"\template\default\forum\forumdisplay.htm"的126-150行
  1. <table cellspacing="0" cellpadding="0" class="fl_tb">
  2.                                                         <!--{loop $recommendgroups $key $group}-->
  3.                                                         <tr {if $key != 0}class="fl_row"{/if}>
  4.                                                                 <td class="fl_icn">
  5.                                                                         <a href="forum.php?mod=group&fid=$group[fid]" title="$group[name]" target="_blank"><img src="$group[icon]" alt="$group[name]" width="32" /></a>
  6.                                                                 </td>
  7.                                                                 <td>
  8.                                                                         <h2><a href="forum.php?mod=group&fid=$group[fid]" target="_blank">$group[name]</a><span class="xg1 xw0"> ($group[membernum] {lang activity_member_unit})</span></h2>
  9.                                                                         <p><!--{echo cutstr($group[description], 100)}--></p>
  10.                                                                 </td>
  11.                                                                 <td class="fl_i">
  12.                                                                         <span class="xi2">$group[threads] {lang index_threads}</span>
  13.                                                                 </td>
  14.                                                                 <td class="fl_by">
  15.                                                                         <div>
  16.                                                                                 <!--{if is_array($group['lastpost'])}-->
  17.                                                                                 <a href="forum.php?mod=redirect&tid=$group[lastpost][tid]&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($group[lastpost][subject], 30)}--></a> <cite>$group[lastpost][dateline] <!--{if $group['lastpost']['author']}--><a href="home.php?mod=space&username={$group[lastpost][encode_author]}">{$group[lastpost][author]}</a><!--{else}-->$_G[setting][anonymoustext]<!--{/if}--></cite>
  18.                                                                                 <!--{else}-->
  19.                                                                                 {lang never}
  20.                                                                                 <!--{/if}-->
  21.                                                                         </div>
  22.                                                                 </td>
  23.                                                         </tr>
  24.                                                         <!--{/loop}-->
  25.                                                 </table>
复制代码
修改为:
  1. <table cellspacing="0" cellpadding="0" class="fl_tb">
  2.                                                         <!--{loop $recommendgroups $key $group}-->
  3.                                                                 <!--{if ($key % $_G['groups']['forumcolumns'] == 0)}-->
  4.                                                                 <tr {if $key != 0}class="fl_row"{/if}>
  5.                                                                 <!--{/if}-->
  6.                                                                 <td class="fl_g" width="$_G[groups][forumcolwidth]"">
  7.                                                                         <div class="fl_icn_g">
  8.                                                                                 <a href="forum.php?mod=group&fid=$group[fid]" title="$group[name]" target="_blank"><img src="$group[icon]" alt="$group[name]" width="32" /></a>
  9.                                                                         </div>
  10.                                                                         <dl>
  11.                                                                                 <dt>
  12.                                                                                         <h2><a href="forum.php?mod=group&fid=$group[fid]" target="_blank">$group[name]</a><span class="xg1 xw0"> ($group[membernum] {lang activity_member_unit})</span></h2>
  13.                                                                                         <p><!--{echo cutstr($group[description], 100)}--></p>
  14.                                                                                 </dt>
  15.                                                                                 <dd>
  16.                                                                                         <span class="xi2">$group[threads] {lang index_threads}</span>
  17.                                                                                 </dd>
  18.                                                                                 <dd>
  19.                                                                                         <!--{if is_array($group['lastpost'])}-->
  20.                                                                                         <a href="forum.php?mod=redirect&tid=$group[lastpost][tid]&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($group[lastpost][subject], 30)}--></a> <cite>$group[lastpost][dateline] <!--{if $group['lastpost']['author']}--><a href="home.php?mod=space&username={$group[lastpost][encode_author]}">{$group[lastpost][author]}</a><!--{else}-->$_G[setting][anonymoustext]<!--{/if}--></cite>
  21.                                                                                         <!--{else}-->
  22.                                                                                         {lang never}
  23.                                                                                         <!--{/if}-->
  24.                                                                                 </dd>
  25.                                                                         </dl>
  26.                                                                 </td>
  27.                                                         <!--{/loop}-->
  28.                                                         $_G['groups']['endrows']
  29.                                                         </tr>
  30.                                                 </table>
复制代码
OK!

 楼主| otherbank 发表于 2011-10-28 12:22:14 | 显示全部楼层
{:soso__13924266534024432323_1:}
回复

使用道具 举报

腐朽的木头 发表于 2011-10-28 12:56:13 | 显示全部楼层
呵呵 不错。。。
回复

使用道具 举报

lxeun 发表于 2011-10-28 14:40:16 来自手机 | 显示全部楼层
不错。。。。。。。。
回复

使用道具 举报

64243354 发表于 2011-10-28 17:43:21 | 显示全部楼层
支持
回复

使用道具 举报

 楼主| otherbank 发表于 2011-10-28 17:59:45 | 显示全部楼层
64243354 发表于 2011-10-28 17:43
支持

3q
回复

使用道具 举报

discuz-x2 发表于 2011-10-28 18:59:58 | 显示全部楼层
本帖最后由 discuz-x2 于 2012-5-15 20:27 编辑

西安婚庆公司  http://www.wedxian.com/
回复

使用道具 举报

吉安同乡会 发表于 2011-10-30 21:47:29 | 显示全部楼层
这贴要顶!
回复

使用道具 举报

ctyoung 发表于 2011-11-1 05:58:15 | 显示全部楼层
嗯!学会了改源码及路径…
回复

使用道具 举报

nnorther 发表于 2011-11-2 10:18:52 | 显示全部楼层
谢谢楼主,  另外我想问,  如果DIY的话,  怎么用这样的群组样式??  能单独拎出来 给我不? 谢谢
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 01:50 , Processed in 0.113661 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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