本帖最后由 otherbank 于 2011-10-28 12:29 编辑
群组推荐到论坛板块后无法横排显示,后台没有这个设置功能,默认一排只能显示一个群组,与上面横排显示的论坛板块不是很协调,如下图:
怎样才能横排显示推荐的群组呢,如下图:
这里讲一个方法,两步可以实现,需要修改程序和模板:
一、找到程序文件的"\source\module\forum\forum_forumdisplay.php"的305-312行:- if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
- $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
- }
- $recommendgroups = array();
- if($_G['forum']['status'] != 3 && $_G['setting']['groupstatus']) {
- loadcache('forumrecommend');
- $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
- }
复制代码 修改为:- if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
- $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
- }
- $recommendgroups = array();
- if($_G['forum']['status'] != 3 && $_G['setting']['groupstatus']) {
- loadcache('forumrecommend');
- $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
- }
- $_G['groups']['forumcolumns'] = 3 ;
- $_G['groups']['forumcolwidth'] = (floor(100 / $_G['groups']['forumcolumns']) - 0.1).'%';
- $_G['groups']['endrows'] = '';
- if($colspan = count($recommendgroups) % $_G['groups']['forumcolumns']) {
- while(($_G['groups']['forumcolumns'] - $colspan) > 0) {
- $_G['groups']['endrows'] .= '<td> </td>';
- $colspan ++;
- }
- $_G['groups']['endrows'] .= '</tr>';
- }
复制代码 “$_G['groups']['forumcolumns'] = 3 ;”的值,既是横排显示的个数,可自由修改。
二、找到模板文件"\template\default\forum\forumdisplay.htm"的126-150行- <table cellspacing="0" cellpadding="0" class="fl_tb">
- <!--{loop $recommendgroups $key $group}-->
- <tr {if $key != 0}class="fl_row"{/if}>
- <td class="fl_icn">
- <a href="forum.php?mod=group&fid=$group[fid]" title="$group[name]" target="_blank"><img src="$group[icon]" alt="$group[name]" width="32" /></a>
- </td>
- <td>
- <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>
- <p><!--{echo cutstr($group[description], 100)}--></p>
- </td>
- <td class="fl_i">
- <span class="xi2">$group[threads] {lang index_threads}</span>
- </td>
- <td class="fl_by">
- <div>
- <!--{if is_array($group['lastpost'])}-->
- <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>
- <!--{else}-->
- {lang never}
- <!--{/if}-->
- </div>
- </td>
- </tr>
- <!--{/loop}-->
- </table>
复制代码 修改为:- <table cellspacing="0" cellpadding="0" class="fl_tb">
- <!--{loop $recommendgroups $key $group}-->
- <!--{if ($key % $_G['groups']['forumcolumns'] == 0)}-->
- <tr {if $key != 0}class="fl_row"{/if}>
- <!--{/if}-->
- <td class="fl_g" width="$_G[groups][forumcolwidth]"">
- <div class="fl_icn_g">
- <a href="forum.php?mod=group&fid=$group[fid]" title="$group[name]" target="_blank"><img src="$group[icon]" alt="$group[name]" width="32" /></a>
- </div>
- <dl>
- <dt>
- <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>
- <p><!--{echo cutstr($group[description], 100)}--></p>
- </dt>
- <dd>
- <span class="xi2">$group[threads] {lang index_threads}</span>
- </dd>
- <dd>
- <!--{if is_array($group['lastpost'])}-->
- <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>
- <!--{else}-->
- {lang never}
- <!--{/if}-->
- </dd>
- </dl>
- </td>
- <!--{/loop}-->
- $_G['groups']['endrows']
- </tr>
- </table>
复制代码 OK!
|