国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

ZBLOG PHP調用隨機文章、熱門文章、熱評文章程序

2024-08-30 19:06:47
字體:
來源:轉載
供稿:網友

本文章來為各位介紹一篇關于ZBLOG PHP調用隨機文章、熱門文章、熱評文章的例子,希望這篇教程能夠為各位同學帶來幫助的哦.

使用方法:

第一、在我們的主題目錄中需要創建include.php文件,如果有就直接添加腳本,代碼如下:

  1. /** 
  2. * 獲取文章列表 
  3. * @param int $count 數量 
  4. * @param null $cate 分類ID 
  5. * @param null $auth 用戶ID 
  6. * @param null $date 日期 
  7. * @param null $tags 標簽 
  8. * @param null $search 搜索關鍵詞 
  9. * @param null $order 排序 
  10. * @param null $option 
  11. * @return array|mixed 
  12. */ 
  13. function TcgetList($count = 10, $cate = null, $auth = null, $date = null, $tags = null, $search = null, $option = null,$order=null) { 
  14. global $zbp
  15.  
  16. if (!is_array($option)) { 
  17. $option = array(); 
  18.  
  19. if (!isset($option['only_ontop'])) 
  20. $option['only_ontop'] = false; 
  21. if (!isset($option['only_not_ontop'])) 
  22. $option['only_not_ontop'] = false; 
  23. if (!isset($option['has_subcate'])) 
  24. $option['has_subcate'] = false; 
  25. if (!isset($option['is_related'])) 
  26. $option['is_related'] = false; 
  27.  
  28. if ($option['is_related']) { 
  29. $at = $zbp->GetPostByID($option['is_related']); 
  30. $tags = $at->Tags; 
  31. if (!$tags
  32. return array(); 
  33. $count = $count + 1; 
  34.  
  35. if ($option['only_ontop'] == true) { 
  36. $w[] = array('=''log_IsTop', 0); 
  37. elseif ($option['only_not_ontop'] == true) { 
  38. $w[] = array('=''log_IsTop', 1); 
  39.  
  40. $w = array(); 
  41. $w[] = array('=''log_Status', 0); 
  42.  
  43. $articles = array(); 
  44.  
  45. if (!is_null($cate)) { 
  46. $category = new Category; 
  47. $category = $zbp->GetCategoryByID($cate); 
  48.  
  49. if ($category->ID > 0) { 
  50.  
  51. if (!$option['has_subcate']) { 
  52. $w[] = array('=''log_CateID'$category->ID); 
  53. else { 
  54. $arysubcate = array(); 
  55. $arysubcate[] = array('log_CateID'$category->ID); 
  56. foreach ($zbp->categorys[$category->ID]->SubCategorys as $subcate) { 
  57. $arysubcate[] = array('log_CateID'$subcate->ID); 
  58. $w[] = array('array'$arysubcate); 
  59.  
  60.  
  61.  
  62. if (!is_null($auth)) { 
  63. $author = new Member; 
  64. $author = $zbp->GetMemberByID($auth); 
  65.  
  66. if ($author->ID > 0) { 
  67. $w[] = array('=''log_AuthorID'$author->ID); 
  68.  
  69. if (!is_null($date)) { 
  70. $datetime = strtotime($date); 
  71. if ($datetime) { 
  72. $datetitle = str_replace(array('%y%''%m%'), array(date('Y'$datetime), date('n'$datetime)), $zbp->lang['msg']['year_month']); 
  73. $w[] = array('BETWEEN''log_PostTime'$datetimestrtotime('+1 month'$datetime)); 
  74.  
  75. if (!is_null($tags)) { 
  76. $tag = new Tag; 
  77. if (is_array($tags)) { 
  78. $ta = array(); 
  79. foreach ($tags as $t) { 
  80. $ta[] = array('log_Tag''%{' . $t->ID . '}%'); 
  81. $w[] = array('array_like'$ta); 
  82. unset($ta); 
  83. else { 
  84. if (is_int($tags)) { 
  85. $tag = $zbp->GetTagByID($tags); 
  86. else { 
  87. $tag = $zbp->GetTagByAliasOrName($tags); 
  88. if ($tag->ID > 0) { 
  89. $w[] = array('LIKE''log_Tag''%{' . $tag->ID . '}%'); 
  90.  
  91. if (is_string($search)) { 
  92. $search=trim($search); 
  93. if ($search!=='') { 
  94. $w[] = array('search''log_Content''log_Intro''log_Title'$search); 
  95.  
  96. if(!emptyempty($order)){ 
  97. if($order=='new'){ 
  98. $order = array('log_PostTime'=>'DESC'); 
  99. if($order=='hot'){ 
  100. $order = array('log_ViewNums'=>'DESC'); 
  101. if($order=='comm'){ 
  102. $order = array('log_CommNums'=>'DESC'); 
  103. if($order=='rand'){ 
  104. $order = array('rand()'=>' '); 
  105.  
  106. $articles = $zbp->GetArticleList('*'$w$order$count, null, false); 
  107. //Vevb.com 
  108. if ($option['is_related']) { 
  109. foreach ($articles as $k => $a) { 
  110. if ($a->ID == $option['is_related']) 
  111. unset($articles[$k]); 
  112. if (count($articles) == $count){ 
  113. array_pop($articles); 
  114.  
  115. return $articles
  116.  

然后就是在我們需要的界面模板中調用。

A - 隨機文章,代碼如下:

  1. {$array=TcgetList(10,null,null,null,null,null,null,'rand');} 
  2. <ul id="related"
  3. {foreach $array as $related
  4. <li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li> 
  5. {/foreach
  6. </ul> 

隨機10篇文章

B - 熱門文章,代碼如下:

  1. {$array=TcgetList(10,null,null,null,null,null,null,'hot');} 
  2. <ul id="related"
  3. {foreach $array as $related
  4. <li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li> 
  5. {/foreach
  6. </ul> 

調用10篇熱門文章

C - 熱評文章,代碼如下:

  1. {$array=TcgetList(10,null,null,null,null,null,null,'comm';} 
  2. <ul id="related"
  3. {foreach $array as $related
  4. <li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li> 
  5. {/foreach
  6. </ul> 

調用10篇熱評文章,具體的根據我們實際使用調用就可以.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 来宾市| 石楼县| 神木县| 邳州市| 招远市| 宁河县| 平罗县| 黑水县| 孝感市| 滦平县| 雅安市| 东乌珠穆沁旗| 自治县| 林口县| 东兴市| 新平| 枞阳县| 神农架林区| 柳林县| 宁波市| 长乐市| 新蔡县| 郸城县| 丰镇市| 辽源市| 荣昌县| 荣成市| 东莞市| 新余市| 乌鲁木齐市| 黔西县| 长海县| 鹰潭市| 开封市| 三穗县| 华宁县| 界首市| 突泉县| 武宣县| 喜德县| 浪卡子县|