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

 找回密码
 立即注册
搜索

[发布] 3.1首页横排调用多条数据 美观实用

[复制链接]
西部园丁 发表于 2014-2-2 12:46:06 | 显示全部楼层 |阅读模式
本帖最后由 西部园丁 于 2014-2-4 20:43 编辑

包括手动修改教程和懒人包,建议用懒人包
网站演示只承三天

截图05.png


一、根目录下找到forum.php
编辑这个文件
找到

  1. runhooks();
复制代码


在下载添加

  1. <p>//帖子调用开始
  2. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  3. $hack_cut_str =60; // 这里修改标题长度
  4. $fids = array();
  5. if (file_exists("./data/cache/cache_forums.php")){
  6. require_once "./data/cache/cache_forums.php";
  7. if (is_array($_DCACHE['forums'])){
  8. foreach ($_DCACHE['forums'] as $k => $v){
  9. if (!strstr(',sub,forum,',','.$v['type'].',')) continue;
  10. $fids[$k] = 5; // 这里是第一处调用条数需要和后面的设置一样。
  11. }
  12. }
  13. }
  14. if (count($fids) < 1){
  15. $query = DB::query("SELECT fid FROM ".DB::table('forum_forum')." WHERE type='forum' OR type='sub'");
  16. while ($row = DB::fetch($query)){
  17. $fids[$row['fid']] = 5; // 这里是第二处调用条数需要和前面的设置一样。
  18. }
  19. }
  20. $limit_counts = 0;</p><p>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. //每版最新主题--结束</p>
复制代码


保存。
二、打开/template/default/forum文件夹
找到
  1.         <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>
  2.          <!--{if empty($forum[redirect])}--><dd><em>{lang forum_threads}: <!--{echo dnumber($forum[threads])}--></em>, <em>{lang forum_posts}: <!--{echo dnumber($forum[posts])}--></em></dd><!--{/if}-->
  3.          <dd>
  4.          <!--{if $forum['permission'] == 1}-->
  5.           {lang private_forum}
  6.          <!--{else}-->
  7.           <!--{if $forum['redirect']}-->
  8.            <a href="$forumurl" class="xi2">{lang url_link}</a>
  9.           <!--{elseif is_array($forum['lastpost'])}-->
  10.            <!--{if $cat['forumcolumns'] < 3}-->
  11.             <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>
  12.            <!--{else}-->
  13.             <a href="forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost">{lang forum_lastpost}: $forum[lastpost][dateline]</a>
  14.            <!--{/if}-->
  15.           <!--{else}-->
  16.            {lang never}
  17.           <!--{/if}-->
  18.          <!--{/if}-->
  19.          </dd>
  20.          <!--{hook/index_forum_extra $forum[fid]}-->
  21.         </dl>
  22.        </td>
  23.       <!--{else}-->
  24.        <td class="fl_icn" {if !empty($forum[extra][iconwidth]) && !empty($forum[icon])} style="width: {$forum[extra][iconwidth]}px;"{/if}>
  25.         <!--{if $forum[icon]}-->
  26.          $forum[icon]
  27.         <!--{else}-->
  28.          <a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}><img src="{IMGDIR}/forum{if $forum[folder]}_new{/if}.gif" alt="$forum[name]" /></a>
  29.         <!--{/if}-->
  30.        </td>
  31.        <td>
  32.         <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>
  33.         <!--{if $forum[description]}--><p class="xg2">$forum[description]</p><!--{/if}-->
  34.         <!--{if $forum['subforums']}--><p>{lang forum_subforums}: $forum['subforums']</p><!--{/if}-->
  35.         <!--{if $forum['moderators']}--><p>{lang forum_moderators}: <span class="xi2">$forum[moderators]</span></p><!--{/if}-->
  36.         <!--{hook/index_forum_extra $forum[fid]}-->
  37.        </td>
  38.        <td class="fl_i">
  39.         <!--{if empty($forum[redirect])}--><span class="xi2"><!--{echo dnumber($forum[threads])}--></span><span class="xg1"> / <!--{echo dnumber($forum[posts])}--></span><!--{/if}-->
  40.        </td>
  41.        <td class="fl_by">
  42.         <div>
  43.         <!--{if $forum['permission'] == 1}-->
  44.          {lang private_forum}
  45.         <!--{else}-->
  46.          <!--{if $forum['redirect']}-->
  47.           <a href="$forumurl" class="xi2">{lang url_link}</a>
  48.          <!--{elseif is_array($forum['lastpost'])}-->
  49.           <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>
  50.          <!--{else}-->
  51.           {lang never}
  52.          <!--{/if}-->
  53.         <!--{/if}-->
  54.         </div>
  55.        </td>
  56.       </tr>
  57.       <tr class="fl_row">
  58.       <!--{/if}-->
  59.       <!--{/loop}-->
  60.       $cat['endrows']
复制代码


删除
然后用附件中提供的修改方法修改

最后保存
接着是进入后台更新缓存
ok

免费下载地址:3.1首页横排调用多条数据20140202
http://www.zgz6.com/thread-521-1-1.html

Desktop.rar

32.07 KB, 下载次数: 848

本人买成30金币

回复

使用道具 举报

 楼主| 西部园丁 发表于 2014-2-2 12:46:50 | 显示全部楼层

修改有风险,请你修改前先备份好自己的文件 。出错后好恢复。
回复

使用道具 举报

easyker 发表于 2014-2-2 16:11:02 | 显示全部楼层
感谢分享列表日期后面多空开点比较好
回复

使用道具 举报

人生写手 发表于 2014-2-2 17:37:04 | 显示全部楼层
已经使用,谢谢楼主免费分享。
回复

使用道具 举报

 楼主| 西部园丁 发表于 2014-2-2 18:14:43 | 显示全部楼层
easyker 发表于 2014-2-2 16:11
感谢分享列表日期后面多空开点比较好

好建议((em:12))
回复

使用道具 举报

寒寺钟声 发表于 2014-2-3 17:04:22 | 显示全部楼层
好东西,好技术~!
回复

使用道具 举报

shychejing 发表于 2014-2-3 20:48:21 | 显示全部楼层
金币不足,可惜了
回复

使用道具 举报

 楼主| 西部园丁 发表于 2014-2-4 20:41:25 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-11 19:29 , Processed in 0.103255 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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