演示图片:

2.png

module.php里面添加如下:

  1. <?php
  2. //30天按点击率排行文章
  3. function getdatelogs($log_num) {
  4. $db = Database::getInstance();
  5. $time = time();
  6. $sql = "SELECT gid,title,comnum FROM ".DB_PREFIX."blog WHERE type='blog' AND date > $time - 30*24*60*60 ORDER BY `views` DESC LIMIT 0,$log_num";
  7. $list = $db->query($sql);
  8. while($row = $db->fetch_array($list)){ ?>
  9. <li class="layout_li"><strong><img src="<?php echo TEMPLATE_URL; ?>/img/hot_1.gif" alt="本月热门"> <?php echo $row['comnum']; ?></strong><a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>"><span><?php echo ++$i;?></span><?php echo $row['title']; ?></a></li>
  10. <?php } ?>
  11. <?php } ?>
  12. <?php
  13. //随机文章
  14. function getRandLog($log_num) {
  15. $db = Database::getInstance();
  16. $sql = "SELECT gid,title,comnum FROM ".DB_PREFIX."blog WHERE type='blog' and hide='n' ORDER BY rand() LIMIT 0,$log_num";
  17. $list = $db->query($sql);
  18. while($row = $db->fetch_array($list)){ ?>
  19. <li class="layout_li"><strong><?php echo gettime($row['gid']);?></strong><a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>"><span></span><?php echo $row['title']; ?></a></li>
  20. <?php } ?>


调用代码:一般都放在首页文件log_list.php

  1. <article class="hot_posts ">
  2. <div class="suiji">
  3. <h3>随机文章</h3>
  4. <ul class="layout_ul">
  5. <li class="layout_li"><?php getRandLog(6);?></li>
  6.  
  7. </ul>
  8. </div>
  9. <div class="hots">
  10. <h3>本月热门</h3>
  11. <ul class="layout_ul">
  12. <li class="layout_li"><?php getdatelogs(6);?></li>
  13. </ul>
  14. </div>
  15. </article>

ccs代码:

  1. .hot_posts {
  2. background-color:#fff;
  3. padding:20px;
  4. position:relative;
  5. font-size:0;
  6. box-shadow:0 0px 20px rgba(160, 160, 160, 0.1);
  7. border-radius:10px;
  8. margin-bottom: 10px;
  9. }
  10. .hot_posts .suiji {
  11. display:inline-block;
  12. vertical-align:top;
  13. width:50%;
  14. padding-right:10px;
  15. }
  16. .hot_posts .hots {
  17. display:inline-block;
  18. vertical-align:top;
  19. width:50%;
  20. padding-left:10px;
  21. }
  22. .hot_posts h3 {
  23. border-bottom:2px #f2f2f2 solid;
  24. padding-bottom:6px;
  25. margin-bottom:8px;
  26. font-size:16px;
  27. margin-top:0;
  28. position:relative;
  29. }
  30. .hot_posts h3:after {
  31. content:"";
  32. color:#ffffff;
  33. position:absolute;
  34. height:2px;
  35. width:30px;
  36. background:#45b6f7;
  37. left:0;
  38. bottom:-2px;
  39. -webkit-transition:all .25s ease-in;
  40. -moz-transition:all .25s ease-in;
  41. transition:all .25s ease-in;
  42. }
  43. .hot_posts .suiji:hover h3:after,
  44. .hot_posts .hots:hover h3:after {
  45. width:100px;
  46. }
  47. .hot_posts ul {
  48. padding:0
  49. }
  50. .hot_posts ul li {
  51. display:block;
  52. padding:8px 0;
  53. -webkit-transition:ease-in-out 0.25s;
  54. transition:ease-in-out 0.25s;
  55. font-size:12px;
  56. }
  57. .hot_posts ul li:hover {
  58. font-size:15px;
  59. -webkit-transition:ease-in-out 0.25s;
  60. transition:ease-in-out 0.25s;
  61. }
  62. .hot_posts ul li a {
  63. display:block;
  64. -ms-text-overflow:ellipsis;
  65. text-overflow:ellipsis;
  66. white-space:nowrap;
  67. overflow:hidden;
  68. line-height:22px;
  69. }
  70. .hot_posts ul li strong {
  71. float:right;
  72. font-weight:normal;
  73. line-height:22px;
  74. padding-left:15px;
  75. }
  76. .hot_posts ul li a>img {
  77. width:30px;
  78. height:22px;
  79. margin-right:4px;
  80. border-radius:5px;
  81. vertical-align:bottom;
  82. }
  83. .hot_posts span {
  84. width:22px;
  85. height:22px;
  86. background-color:#f2f2f2;
  87. display:inline-block;
  88. text-align:center;
  89. margin-right:4px;
  90. border-radius:25px;
  91. line-height:22px;
  92. color:#666;
  93. }
  94. .hot_posts ul li:nth-child(1) span {
  95. background-color:#ff5a3c;
  96. color:#fff;
  97. }
  98. .hot_posts ul li:nth-child(2) span {
  99. background-color:#13b755;
  100. color:#fff;
  101. }
  102. .hot_posts ul li:nth-child(3) span {
  103. background-color:#00a9e3;
  104. color:#fff;
  105. }
  106. @media screen and (max-width: 768px) {
  107. .hot_posts .suiji {
  108. width:100%;
  109. margin-bottom:20px;
  110. }
  111. .hot_posts .hots {
  112. width:100%;
  113. padding-left:0;
  114. }
  115. }


以下图片放到当前模板文件夹/img/hot_1.gif

hot_1.gif