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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

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

[复制链接]
烛光之窗 发表于 2014-2-2 13:22:50 | 显示全部楼层 |阅读模式
包括手动修改教程和懒人包
演示地址:www.zgz6.com




一、根目录下找到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

友情提示:修改有风险,请你备份好自己的文件 。遇到有错好恢复。

本帖子中包含更多资源

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

x
1314学习网 发表于 2014-2-2 13:33:08 | 显示全部楼层
没判断是否是论坛首页,这使得论坛每个页面都要做这些数据库查询

AD:首页版块N格 https://addon.dismall.com/?@study_forum_nge.plugin
回复

使用道具 举报

 楼主| 烛光之窗 发表于 2014-2-23 09:26:20 | 显示全部楼层
哪个又翻出来了?本站已经重新了。
回复

使用道具 举报

9axl 发表于 2014-7-6 20:38:06 | 显示全部楼层
学生网-http://www.9axl.com已经加以改进.更加漂亮.
回复

使用道具 举报

 楼主| 烛光之窗 发表于 2014-7-12 19:02:11 | 显示全部楼层
9axl 发表于 2014-7-6 20:38
学生网-http://www.9axl.com已经加以改进.更加漂亮.

长江后浪推前浪。
回复

使用道具 举报

9axl 发表于 2014-7-28 21:34:28 | 显示全部楼层

感谢
回复

使用道具 举报

难得有雨 发表于 2014-7-28 22:26:03 | 显示全部楼层
好东西啊,这代码也太好了,正适用呢


永夜君王www.wanjuanba.com/25/25331/ 永夜君王最新章节列表 章一 绯色 章二 站着沉默。终极教师 www.wanjuanba.com/26/26257/ 终极教师第一条,禁止师生恋! 第二条,禁止师生恋!遮天www.wanjuanba.com/0/2/遮天最新章节:正文 完本感言。星战风暴www.wanjuanba.com/22/22255/星战风暴军校考试临近,殉情之名不胫而走。
回复

使用道具 举报

sagitary 发表于 2014-11-20 19:28:37 | 显示全部楼层
本帖最后由 sagitary 于 2014-11-20 19:30 编辑

你好, 使用你的美化插件, 但由于我的网站里面某些分区是带子版块的, 所以不能在首页显示最新的几个贴子, 可否修改下你的代码, 可以提取分区下面比如四到五个版块的最新贴显示在首页呢? 另外,我不需要显示有无版主,最后发表, 版主列表 , 最后发表:暂无主题, 抢先发表这些都不要。 只要显示最新的5个贴子标题,再把主题数和贴子数显示在版块名字右边同一行即可。
可否加我好友然后QQ 谈? 以后还需要别的代码修改需求。

这次的代码修改,我可以先付费。 但由于比较简单,初次合作,希望价格合理。谢谢。
回复

使用道具 举报

xyaung 发表于 2015-8-26 22:52:07 | 显示全部楼层
这个不错,明天试一下咯你
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 06:20 , Processed in 0.114078 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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