杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 5792|回复: 0

[Discuz] Discuz X3.2自带首页四格代码解读

[复制链接]
发表于 2014-11-21 15:07:23 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

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

x
Discuz X3自带首页四格开启位置为:后台——论坛——首页四格。

首页四格代码展示位置:template\default\forum\discuz.htm
默认代码如下:
  1. <!–{if !empty($_G['setting']['grid']['showgrid'])}–>
  2. <!– index four grid –>
  3. <div class="fl bm">
  4. <div class="bm bmw cl">
  5. <div id="category_grid" class="bm_c" >
  6. <table cellspacing="0" cellpadding="0"><tr>
  7. <!–{if !$_G['setting']['grid']['gridtype']}–>
  8. <td valign="top" class="category_l1">
  9. <div class="newimgbox">
  10. <h4><span class="tit_newimg"></span>{lang latest_images}</h4>
  11. <div class="module cl slidebox_grid" style="width:218px">
  12. <script type="text/javascript">
  13. var slideSpeed = 5000;
  14. var slideImgsize = [218,200];
  15. var slideBorderColor = ‘{$_G['style']['specialborder']}’;
  16. var slideBgColor = ‘{$_G['style']['commonbg']}’;
  17. var slideImgs = new Array();
  18. var slideImgLinks = new Array();
  19. var slideImgTexts = new Array();
  20. var slideSwitchColor = ‘{$_G['style']['tabletext']}’;
  21. var slideSwitchbgColor = ‘{$_G['style']['commonbg']}’;
  22. var slideSwitchHiColor = ‘{$_G['style']['specialborder']}’;
  23. {eval $k = 1;}
  24. <!–{loop $grids['slide'] $stid $svalue}–>
  25. slideImgs[<!--{echo $k}-->] = ‘$svalue[image]‘;
  26. slideImgLinks[<!--{echo $k}-->] = ‘{$svalue[url]}’;
  27. slideImgTexts[<!--{echo $k}-->] = ‘$svalue[subject]‘;
  28. {eval $k++;}
  29. <!–{/loop}–>
  30. </script>
  31. <script language="javascript" type="text/javascript" src="{$_G[setting][jspath]}forum_slide.js?{VERHASH}"></script>
  32. </div>
  33. </div>
  34. </td>
  35. <!–{/if}–>
  36. <td valign="top" class="category_l2">
  37. <div class="subjectbox">
  38. <h4><span class="tit_subject"></span>{lang collection_lastthread}</h4>
  39. <ul class="category_newlist">
  40. <!–{loop $grids['newthread'] $thread}–>
  41. <!–{if !$thread['forumstick'] && $thread['closed'] > 1 && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}–>
  42. <!–{eval $thread[tid]=$thread[closed];}–>
  43. <!–{/if}–>
  44. <li><a href="forum.php?mod=viewthread&tid=$thread[tid]&extra=$extra"{if $thread['highlight']} $thread['highlight']{/if}{if $_G['setting']['grid']['showtips']} tip="{lang title}: <strong>$thread[oldsubject]</strong><br/>{lang author}: $thread[author] ($thread[dateline])<br/>{lang show}/{lang reply}: $thread[views]/$thread[replies]" onmouseover="showTip(this)"{else} title="$thread[oldsubject]"{/if}{if $_G['setting']['grid']['targetblank']} target="_blank"{/if}>$thread[subject]</a></li>
  45. <!–{/loop}–>
  46. </ul>
  47. </div>
  48. </td>
  49. <td valign="top" class="category_l3">
  50. <div class="replaybox">
  51. <h4><span class="tit_replay"></span>{lang show_newthreads}</h4>
  52. <ul class="category_newlist">
  53. <!–{loop $grids['newreply'] $thread}–>
  54. <!–{if !$thread['forumstick'] && $thread['closed'] > 1 && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}–>
  55. <!–{eval $thread[tid]=$thread[closed];}–>
  56. <!–{/if}–>
  57. <li><a href="forum.php?mod=redirect&tid=$thread[tid]&goto=lastpost#lastpost"{if $thread['highlight']} $thread['highlight']{/if}{if $_G['setting']['grid']['showtips']}tip="{lang title}: <strong>$thread[oldsubject]</strong><br/>{lang author}: $thread[author] ($thread[dateline])<br/>{lang show}/{lang reply}: $thread[views]/$thread[replies]" onmouseover="showTip(this)"{else} title="$thread[oldsubject]"{/if}{if $_G['setting']['grid']['targetblank']} target="_blank"{/if}>$thread[subject]</a></li>
  58. <!–{/loop}–>
  59. </ul>
  60. </div>
  61. </td>
  62. <td valign="top" class="category_l3">
  63. <div class="hottiebox">
  64. <h4><span class="tit_hottie"></span>{lang hot_thread}</h4>
  65. <ul class="category_newlist">
  66. <!–{loop $grids['hot'] $thread}–>
  67. <!–{if !$thread['forumstick'] && $thread['closed'] > 1 && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}–>
  68. <!–{eval $thread[tid]=$thread[closed];}–>
  69. <!–{/if}–>
  70. <li><a href="forum.php?mod=viewthread&tid=$thread[tid]&extra=$extra"{if $thread['highlight']} $thread['highlight']{/if}{if $_G['setting']['grid']['showtips']} tip="{lang title}: <strong>$thread[oldsubject]</strong><br/>{lang author}: $thread[author] ($thread[dateline])<br/>{lang show}/{lang reply}: $thread[views]/$thread[replies]" onmouseover="showTip(this)"{else} title="$thread[oldsubject]"{/if}{if $_G['setting']['grid']['targetblank']} target="_blank"{/if}>$thread[subject]</a></li>
  71. <!–{/loop}–>
  72. </ul>
  73. </div>
  74. </td>
  75. <!–{if $_G['setting']['grid']['gridtype']}–>
  76. <td valign="top" class="category_l4">
  77. <div class="goodtiebox">
  78. <h4><span class="tit_goodtie"></span>{lang post_digest_thread}</h4>
  79. <ul class="category_newlist">
  80. <!–{loop $grids['digest'] $thread}–>
  81. <!–{if !$thread['forumstick'] && $thread['closed'] > 1 && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}–>
  82. <!–{eval $thread[tid]=$thread[closed];}–>
  83. <!–{/if}–>
  84. <li><a href="forum.php?mod=viewthread&tid=$thread[tid]&extra=$extra"{if $thread['highlight']} $thread['highlight']{/if}{if $_G['setting']['grid']['showtips']} tip="{lang title}: <strong>$thread[oldsubject]</strong><br/>{lang author}: $thread[author] ($thread[dateline])<br/>{lang show}/{lang reply}: $thread[views]/$thread[replies]" onmouseover="showTip(this)"{else} title="$thread[oldsubject]"{/if}{if $_G['setting']['grid']['targetblank']} target="_blank"{/if}>$thread[subject]</a></li>
  85. <!–{/loop}–>
  86. </ul>
  87. </div>
  88. </td>
  89. <!–{/if}–>
  90. </table>
  91. </div>
  92. </div>
  93. </div>
  94. <!– index four grid end –>
  95. <!–{/if}–>
复制代码
以上个别代码说明:
  1. {eval $k = 1;}
  2. <!–{loop $grids['slide'] $stid $svalue}–>
  3. slideImgs[<!--{echo $k}-->] = ‘$svalue[image]‘;
  4. slideImgLinks[<!--{echo $k}-->] = ‘{$svalue[url]}’;
  5. slideImgTexts[<!--{echo $k}-->] = ‘$svalue[subject]‘;
  6. {eval $k++;}
复制代码
表示图片幻灯片从1开始,有一个幻灯片就会加1,这样会一直循环下去。比如只想显示5张幻灯图片,把$k++改成$k = 5即可。
  1. var slideSpeed = 5000;
  2. var slideImgsize = [218,200];
复制代码
slideSpeed表示播放速度,slideImgsize表示播放窗口大小。
category_l1是幻灯图片代码区{lang latest_images},category_l2是最后回复{lang collection_lastthread},category_l3是最新帖子{lang show_newthreads}和热门{lang hot_thread},category_l4是精华帖子{lang post_digest_thread},对照代码看,再自己编辑吧

首页四格代码CSS位置:template\default\common\module.css
默认代码如下:
  1. /* 论坛首页四格 by Alice */
  2. #category_grid { padding: 0; border-top:1px solid {COMMONBORDER}; }
  3. #category_grid table { width:100%;table-layout: fixed; }
  4. #category_grid td { width: 25%; }
  5. .category_l1, .category_l2, .category_l3, .category_l4 { line-height: 25px; background: #fff; overflow: hidden; }
  6. .category_l1 { line-height: normal; }
  7. .category_l1, .category_l2, .category_l3 { background: url({IMGDIR}/category_lbg.png) no-repeat right center; }
  8. .ie6 .category_l4 { margin-right: -3px; }
  9. .slidebox_grid { position: relative; margin: 10px; border: 1px #ccc solid; }
  10. #category_grid h4 { width:100%; height: 30px; line-height: 30px; text-indent:10px; font-size: 12px; cursor: pointer; background: url({IMGDIR}/tb.png) repeat-x; position:relative; }
  11. .category_newlist { padding: 10px; }
  12. .category_newlist li { background:url({IMGDIR}/dot.gif) no-repeat left center;  height: 21px; line-height:21px; overflow: hidden; padding-left:10px; }
  13. #category_grid h4 span { background:#CDCDCD; width:1px; height:30px; display:inline-block; position:absolute; left:0; top:0; }
  14. #category_grid h4 span.tit_newimg { background:#FFF; }
  15. #category_grid .newimgbox:hover h4 span, #category_grid .subjectbox:hover h4 span, #category_grid .replaybox:hover h4 span, #category_grid .hottiebox:hover h4 span, #category_grid .goodtiebox:hover h4 span { width:6px; background:url({IMGDIR}/grid.png) no-repeat 0 0;transition:width 0.2s ease 0s; overflow:hidden; }
  16. #category_grid .newimgbox:hover h4 span.tit_newimg { background-position:0 -30px; }
  17. #category_grid .subjectbox:hover h4 span.tit_subject { background-position:0 0; }
  18. #category_grid .repalybox:hover h4 span.tit_replay { background-position:0 -30px; }
  19. #category_grid .hottiebox:hover h4 span.tit_hottie { background-position:0 -60px; }
  20. #category_grid .goodtiebox:hover h4 span.tit_goodtie { background-position:0 -90px; }
复制代码
共同探讨,比较喜欢自带的插件!

解决X3自带首页四格最新主题和最新回复一样的问题

由于source\class\table\table_forum_thread.php文件中调用新主题的参数是 newthread,第1105行
  1. if($type == ‘newthread’) {
复制代码
而source\module\forum\forum_index.php里却是thread,所以默认还是调用的最新回复贴子
  1. $grids['newthread'] = C::t(‘forum_thread’)->fetch_all_for_guide(‘thread’, 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
复制代码
修改 thread为newthread即可,如下第159行
  1. $grids['newthread'] = C::t(‘forum_thread’)->fetch_all_for_guide(‘newthread’, 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
复制代码
解决X3自带首页四格幻灯图片最新的图片不在第一显示的问题

X3自带的首页四格幻灯图片的 图片路径、名称==都存放在$grids['slide']数组中
增加一行,对$grids['slide']数组进行一下排序就能让最新的图片显示在第1的位置。
找到source\module\forum\forum_index.php
  1. $grids['slide'][$ithread['tid']] = array(
  2. ‘image’ => $imageurl,
  3. ‘url’ => ‘forum.php?mod=viewthread&tid=’.$ithread['tid'],
  4. ‘subject’ => $ithread['subject']
  5. );
复制代码
在上面代码下面增加:
  1. rsort($grids['slide']);
复制代码
即修改成如下所示代码:
  1. $grids['slide'][$ithread['tid']] = array(
  2. ‘image’ => $imageurl,
  3. ‘url’ => ‘forum.php?mod=viewthread&tid=’.$ithread['tid'],
  4. ‘subject’ => $ithread['subject']
  5. );
  6. rsort($grids['slide']);
  7. }
  8. }
  9. $grids['cachetime'] = TIMESTAMP;
复制代码
回复

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-6 09:17 , Processed in 0.110901 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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