DedeCMS织梦

织梦DedeCMS列表页获取访客热搜排行榜文章的方法

阿里云

织梦 DedeCMS 列表页获取访客热搜排行榜文章的方法,方法比较简单只需要打开织梦/include/extend.func.php 最后加上以下代码:

  1. //列表页获取网友热搜 24小时
  2. function jjGetHotSearch($tid){
  3. global $dsql;
  4. $time = time() - 86400;
  5. $sql = "select * from  dede_archives where typeid = '$tid' and shorttitle <> '' group by shorttitle order by pubdate desc limit 10";
  6. $dsql->Execute('me',$sql);
  7. $li = '';
  8. while($arr = $dsql->GetArray('me'))
  9. {
  10. if($arr['pubdate'] >$time ){
  11. $class = 'new';
  12. }else{
  13. $class = '';
  14. }
  15. $barr = GetOneArchive($arr['id']);
  16. $arcurl = $barr['arcurl'];
  17. $li .= '<li><span class="right"><time class="'.$class.'">'.date('Y-m-d',$arr['pubdate']).'</time></span><a href="'.$arcurl.'" title="'.$arr['shorttitle'].'">'.$arr['shorttitle'].'</a></li>';
  18. } 
  19. return $li;
  20. }
  21.  
  22. //排行榜获取网友热搜 3天
  23. function hot_3_GetHotSearch($tid){
  24. global $dsql;
  25. $time = time() - 86400;
  26. $sql = "select * from  dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) - INTERVAL 3 day) and typeid = '$tid' and shorttitle <> '' group by shorttitle order by click desc limit 10";
  27. $dsql->Execute('me',$sql);
  28. $li = '';
  29. while($arr = $dsql->GetArray('me'))
  30. {
  31. if($arr['pubdate'] >$time ){
  32. $class = 'new';
  33. }else{
  34. $class = '';
  35. }
  36. $barr = GetOneArchive($arr['id']);
  37. $arcurl = $barr['arcurl'];
  38. $li .= '<li><span class="right"><time class="'.$class.'">'.date('Y-m-d',$arr['pubdate']).'</time></span><a href="'.$arcurl.'" title="'.$arr['shorttitle'].'">'.$arr['shorttitle'].'</a></li>';
  39. } 
  40. return $li;
  41. }
  42.  
  43.  
  44. //排行榜获取网友热搜 7天
  45. function hot_7_GetHotSearch($tid){
  46. global $dsql;
  47. $time = time() - 86400;
  48. $sql = "select * from  dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) - INTERVAL 7 day) and typeid = '$tid' and shorttitle <> '' group by shorttitle order by click desc limit 10";
  49. $dsql->Execute('me',$sql);
  50. $li = '';
  51. while($arr = $dsql->GetArray('me'))
  52. {
  53. if($arr['pubdate'] >$time ){
  54. $class = 'new';
  55. }else{
  56. $class = '';
  57. }
  58. $barr = GetOneArchive($arr['id']);
  59. $arcurl = $barr['arcurl'];
  60. $li .= '<li><span class="right"><time class="'.$class.'">'.date('Y-m-d',$arr['pubdate']).'</time></span><a href="'.$arcurl.'" title="'.$arr['shorttitle'].'">'.$arr['shorttitle'].'</a></li>';
  61. } 
  62. return $li;
  63. }
  64.  
  65.  
  66. //排行榜获取网友热搜 30天
  67. function hot_30_GetHotSearch($tid){
  68. global $dsql;
  69. $time = time() - 86400;
  70. $sql = "select * from  dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) - INTERVAL 30 day) and typeid = '$tid' and shorttitle <> '' group by shorttitle order by click desc limit 10";
  71. $dsql->Execute('me',$sql);
  72. $li = '';
  73. while($arr = $dsql->GetArray('me'))
  74. {
  75. if($arr['pubdate'] >$time ){
  76. $class = 'new';
  77. }else{
  78. $class = '';
  79. }
  80. $barr = GetOneArchive($arr['id']);
  81. $arcurl = $barr['arcurl'];
  82. $li .= '<li><span class="right"><time class="'.$class.'">'.date('Y-m-d',$arr['pubdate']).'</time></span><a href="'.$arcurl.'" title="'.$arr['shorttitle'].'">'.$arr['shorttitle'].'</a></li>';
  83. } 
  84. return $li;
  85. }
  86.  
  87.  
  88. //列表页获取栏目关注 30天 14条
  89. function hotword_30_GetHotSearch($tid){
  90. global $dsql;
  91. $time = time() - 86400;
  92. $sql = "select * from  dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) - INTERVAL 90 day) and typeid = '$tid' and shorttitle <> '' group by shorttitle order by click desc limit 14";
  93. $dsql->Execute('me',$sql);
  94. $li = '';
  95. while($arr = $dsql->GetArray('me'))
  96. {
  97. if($arr['pubdate'] >$time ){
  98. $class = 'new';
  99. }else{
  100. $class = '';
  101. }
  102. $barr = GetOneArchive($arr['id']);
  103. $arcurl = $barr['arcurl'];
  104. $li .= '<a href="'.$arcurl.'" title="'.$arr['shorttitle'].'">'.$arr['shorttitle'].'</a>';
  105. } 
  106. return $li;
  107. }
也想出现在这里?联系我们
创客主机

列表调用方法:{dede:field.id function=jjGetHotSearch(@me)/},其他函数调用方法也是一样的,自己修改下 jjGetHotSearch 名称就可以了 。

织梦 DedeCMS 列表页获取访客热搜排行榜文章的方法

已有 304 人购买
查看演示升级 VIP立刻购买

收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!