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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] Discuz!X2.5 论坛横排美化,调用多条数据(懒人包)

[复制链接]
haodepeng 发表于 2012-10-10 13:57:20 | 显示全部楼层 |阅读模式
先发个效果网站  http://www.c88.in

我看到好动朋友在找,我一开始也百度过几个都不管用,今天为大家发布个行的
收费一个金币哈 我是穷怕的
(懒人包)是时候官方论坛模板的 如果是自己的模板那么还是要手动修改的

一、打开 forum.php 查找
  1. $navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
复制代码
在下面添加
  1. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  2. $hack_cut_str =60; // 这里修改标题长度
  3. $fids = array();
  4. if (file_exists("./data/cache/cache_forums.php")){
  5. require_once "./data/cache/cache_forums.php";
  6. if (is_array($_DCACHE['forums'])){
  7. foreach ($_DCACHE['forums'] as $k => $v){
  8. if (!strstr(',sub,forum,',','.$v['type'].',')) continue;
  9. $fids[$k] = 5; // 这里是第一处调用条数需要和后面的设置一样。
  10. }
  11. }
  12. }
  13. if (count($fids) < 1){
  14. $query = DB::query("SELECT fid FROM ".DB::table('forum_forum')." WHERE type='forum' OR type='sub'");
  15. while ($row = DB::fetch($query)){
  16. $fids[$row['fid']] = 5; // 这里是第二处调用条数需要和前面的设置一样。
  17. }
  18. }
  19. $limit_counts = 0;

  20. foreach ($fids as $k => $v){
  21. $sql .= "(SELECT t.*, f.name FROM ".DB::table('forum_thread')." t LEFT JOIN ".DB::table('forum_forum')." f ON f.fid = t.fid WHERE t.fid='$k' AND t.closed NOT LIKE 'moved|%' AND t.displayorder>=0 ORDER BY t.dateline DESC LIMIT $v) UNION ";
  22. }
  23. if ($sql){
  24. $sql = substr($sql,0,strlen($sql)-6);
  25. }
  26. $query = DB::query($sql);
  27. while ($row = DB::fetch($query)){
  28. $row['view_subject'] = cutstr($row['subject'],$hack_cut_str);
  29. $row['date']= gmdate('m-d/H:i', $row['dateline'] + $_G['setting']['timeoffset'] * 3600);
  30. if($row['highlight']) {
  31. $string = sprintf('%02d', $row['highlight']);
  32. $stylestr = sprintf('%03b', $string[0]);
  33. $row['highlight'] = 'style="';
  34. $row['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  35. $row['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  36. $row['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  37. $row['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  38. $row['highlight'] .= '"';
  39. } else {
  40. $row['highlight'] = '';
  41. }
  42. ${'new_no'.$row['fid'].'_threadlist'}[] = $row;
  43. }
  44. //每版最新主题--结束
复制代码
打开 template/default/forum/discuz.htm 查找
  1. <!--{if $forum['orderid'] && ($forum['orderid'] % $cat['forumcolumns'] == 0)}-->
  2. </tr>
  3. <!--{if $forum['orderid'] < $cat['forumscount']}-->
  4. <tr class="fl_row">
  5. <!--{/if}-->
  6. <!--{/if}-->
  7. <td class="fl_g" width="$cat[forumcolwidth]">
  8. <div class="fl_icn_g"{if !empty($forum[extra][iconwidth]) && !empty($forum[icon])} style="width: {$forum[extra][iconwidth]}px;"{/if}>
  9. <!--{if $forum[icon]}-->
  10. $forum[icon]
  11. <!--{else}-->
  12. <a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}><img src="{IMGDIR}/forum{if $forum[folder]}_new{/if}.gif" alt="$forum[name]" /></a>
  13. <!--{/if}-->
  14. </div>
  15. <dl{if !empty($forum[extra][iconwidth]) && !empty($forum[icon])} style="margin-left: {$forum[extra][iconwidth]}px;"{/if}>
  16. <dt><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}--></dt>
  17. <!--{if empty($forum[redirect])}--><dd><em>{lang forum_threads}: $forum[threads]</em>, <em>{lang forum_posts}: $forum[posts]</em></dd><!--{/if}-->
  18. <dd>
  19. <!--{if $forum['permission'] == 1}-->
  20. {lang private_forum}
  21. <!--{else}-->
  22. <!--{if $forum['redirect']}-->
  23. <a href="$forumurl" class="xi2">{lang url_link}</a>
  24. <!--{elseif is_array($forum['lastpost'])}-->
  25. <!--{if $cat['forumcolumns'] < 3}-->
  26. <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}-->{lang anonymous}<!--{/if}--></cite>
  27. <!--{else}-->
  28. <a href="forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost">{lang forum_lastpost}: $forum[lastpost][dateline]</a>
  29. <!--{/if}-->
  30. <!--{else}-->
  31. {lang never}
  32. <!--{/if}-->
  33. <!--{/if}-->
  34. </dd>
  35. </dl>
  36. </td>
复制代码
替换成
  1. <!--开始 -->
  2. <!--{if $forum['orderid'] && ($forum['orderid'] % $cat['forumcolumns'] == 0)}-->
  3. </tr>
  4. <!--{if $forum['orderid'] < $cat['forumscount']}-->
  5. <tr class="fl_row">
  6. <!--{/if}-->
  7. <!--{/if}-->
  8. <td class="fl_g" width="$cat[forumcolwidth]" style="padding:10px; ">
  9. <div class="b-top w100">
  10. <div class="b-name">
  11. <h2 class="margin"><a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}{if $forum[extra][namecolor]} style="color: {$forum[extra][namecolor]};"{/if}>$forum[name]</a></h2>
  12. </div>
  13. <div class="ctrl" style="float:right;">
  14. <a href="$forumurl&filter=author&orderby=dateline" title="依发布时间排序主题 [进入本版]"><img src="images/dateline_url.gif"></a>
  15. <img src="images/master.gif" class="hand" onclick="toggle_collapse('lastpost_$forum[fid]');" title="最后发表.版主 [收/展]" />
  16. <img src="images/dateline.gif" class="hand" onclick="toggle_collapse('dateline_$forum[fid]');" title="本版最新话题 [展/收]" />
  17. <span style="today-post">
  18. <!--{if $forum[todayposts] && !$forum['redirect']}--><em class="p-yes" title="今日帖数:$forum[todayposts]">$forum[todayposts]</em><!--{else}--><em class="p-no" title="今日帖数:0">0</em><!--{/if}-->
  19. </span>
  20. </div>
  21. </div>

  22. <div class="clear w100">
  23. <div class="b-icon">$forum[icon]</div><div class="b-des">$forum[description]<!--{if $forum['subforums']}--><p>{lang forum_subforums}: $forum['subforums']</p><!--{/if}--></div>
  24. </div>

  25. <div class="clear b-thread" style="background: url(images/listbg_li.gif) no-repeat;">
  26. <ul id="dateline_$forum[fid]" style="display:none;" class="list">
  27. <!--{loop ${"new_no".$forum[fid]."_threadlist"} $row}-->
  28. <div class="t_no-pms">
  29. <!--{if $forum['permission'] == 1}-->
  30. {lang private_forum}, 您目前没有权限可查阅主题及内容
  31. <!--{else}-->
  32. <small class="t_date">$row['date']</small><a href="forum.php?mod=viewthread&tid=$row[tid]" $row[highlight] title="$row[subject] ($row['date'])" target='_self'>$row[view_subject]</a>
  33. <!--{/if}-->
  34. </div>
  35. <!--{/loop}-->
  36. </ul>
  37. </div>

  38. <div id="lastpost_$forum[fid]">
  39. <div class="clear t-lastpost w100">
  40. <!--{if $forum['permission'] == 1}-->
  41. {lang forum_lastpost}: {lang private_forum}
  42. <!--{else}-->
  43. <!--{if $forum['redirect']}-->
  44. {lang forum_lastpost}: <a href="$forumurl" class="xi2">{lang url_link}</a>
  45. <!--{elseif is_array($forum['lastpost'])}-->
  46. {lang forum_lastpost}: <a href="forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost" class="xi2"><!--{echo cutstr($forum[lastpost][subject], 25)}--></a> <cite><!--{if $forum['lastpost']['author']}-->(by $forum['lastpost']['author'])<!--{else}-->{lang anonymous}<!--{/if}--></cite>
  47. <!--{else}-->
  48. {lang forum_lastpost}: {lang never}
  49. <!--{/if}-->
  50. <!--{/if}-->
  51. </div>
  52. <div style="clear mod w100">
  53. <!--{if $forum['moderators']}-->{lang forum_moderators}: <span class="xi2">$forum[moderators]</span> | <!--{/if}-->
  54. {lang forum_threads}:$forum[threads] {lang forum_posts}:$forum[posts]
  55. </div>
  56. </div>
  57. </td>
  58. <!--结束 -->
复制代码
打开 template/default/common/header.htm
在</head> 上添加
  1. <script language="JavaScript">
  2. <!-- Hide
  3. function killErrors() {
  4. return true;
  5. }
  6. window.onerror = killErrors;
  7. // -->
  8. </script>
复制代码
打开 template/default/common/common.css
在最后面添加
  1. /*横排美化*/

  2. /*~~~~~~~~~~~ EXTRA Common~~~~~~~~~~~~~*/

  3. .hand { cursor:hand; cursor: pointer; }
  4. .clear { clear:both; }
  5. .w100 { width:100%; }
  6. /*~~~~~~~~~~~ EXTRA Index Forumlist~~~~~~~~~~~~~*/

  7. .forumlist th.board { vertical-align: top; background-image: none; padding:10px !important; }
  8. div.b-top { display:block; width:100%; overflow: hidden; }
  9. div.b-name { float:left; height: 20px; width:60%; overflow:hidden; }
  10. div.b-name h2.margin { margin:0 0 3px 0; }
  11. div.crtl { float:right; text-align:right; }
  12. div.ctrl img { vertical-align:middle; margin:1px 0; }
  13. span.today-post em, span.today-post em b { font-family: Verdana, Arial, Helvetica, sans-serif; }
  14. em.p-yes { padding:0 5px; border:1px solid #F06; background:#FFFFE1; color:#F06; font-size:11px; font-weight:bold; }
  15. em.p-no { padding:0 5px; border:1px solid #CCC; font-size:11px; }
  16. div.b-icon { float:left; }
  17. div.b-des { color:{LIGHTTEXT}; overflow:hidden; }
  18. div.b-thread { margin-top:5px; padding:1px 0; background-image: url(images/listbg_li.gif) no-repeat; width:100%; }
  19. div.b-thread ul.list { padding:0 2px 0 10px; list-style-type: none; line-height: 20px; }
  20. div.b-thread ul.list .t_no-pms { overflow: hidden; height:20px; width:100% }
  21. div.b-thread ul.list .t_date { float:right; color:{LIGHTTEXT}; margin: 0 0 0 5px }
  22. div.t-lastpost { color:{LIGHTTEXT}; margin-top:5px;overflow: hidden; height:1.3em; }
  23. div.mod { color:{LIGHTTEXT}; overflow: hidden; height:1.5em; }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

评分

2

查看全部评分

9测网 发表于 2012-10-10 14:01:40 | 显示全部楼层
好东西,顶一下。
回复

使用道具 举报

www.winqb.com 发表于 2012-10-10 15:48:04 | 显示全部楼层
不错

深圳论坛_SZ_深圳_鹏城-深圳城市生活社区,请到http://www.chaxb.com

免费DZ、PW、PHPCMS、wordpress风格和免费插件,问题求助、交流,请到http://www.winqb.com

美女、性感、想看mm请到http://www.winqb.net
回复

使用道具 举报

anluan 发表于 2012-10-10 15:48:09 | 显示全部楼层
辛苦!支持一下!
回复

使用道具 举报

 楼主| haodepeng 发表于 2012-10-15 14:36:28 | 显示全部楼层
本帖被以下淘专辑推荐  哈哈哈 第一次{:soso_e113:}
回复

使用道具 举报

zdq201212 发表于 2012-10-15 17:02:53 | 显示全部楼层
谢谢分享。学习一下。
回复

使用道具 举报

1314学习网 发表于 2012-10-22 09:55:51 | 显示全部楼层
前排支持。。。。
回复

使用道具 举报

8#
无效楼层,该帖已经被删除
9axl 发表于 2012-10-27 13:15:01 | 显示全部楼层
本帖最后由 9axl 于 2012-10-27 13:17 编辑

请问调用的数居怎么不显示?http://www.0517e.org/forum.php
回复

使用道具 举报

lishiminv 发表于 2012-10-27 21:19:52 | 显示全部楼层
很好,一直在找啊
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-28 08:03 , Processed in 0.208153 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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