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

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

ZBLOG調用隨機文章、熱門文章、熱評文章的php代碼

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

Z-Blog是由RainbowSoft Studio開發的一款小巧而強大的基于Asp/php平臺的Blog程序了,下文介紹的是php版本的ZBLOG調用隨機文章、熱門文章、熱評文章代碼.

使用方法:

第一、在我們的主題目錄中需要創建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. if (!is_array($option)) { 
  16. $option = array(); 
  17. if (!isset($option['only_ontop'])) 
  18. $option['only_ontop'] = false; 
  19. if (!isset($option['only_not_ontop'])) 
  20. $option['only_not_ontop'] = false; 
  21. if (!isset($option['has_subcate'])) 
  22. $option['has_subcate'] = false; 
  23. if (!isset($option['is_related'])) 
  24. $option['is_related'] = false; 
  25. if ($option['is_related']) { 
  26. $at = $zbp->GetPostByID($option['is_related']); 
  27. $tags = $at->Tags; 
  28. if (!$tags
  29. return array(); 
  30. $count = $count + 1; 
  31. if ($option['only_ontop'] == true) { 
  32. $w[] = array('=''log_IsTop', 0); 
  33. elseif ($option['only_not_ontop'] == true) { 
  34. $w[] = array('=''log_IsTop', 1); 
  35. $w = array(); 
  36. $w[] = array('=''log_Status', 0); 
  37. $articles = array(); 
  38. if (!is_null($cate)) { 
  39. $category = new Category; 
  40. $category = $zbp->GetCategoryByID($cate); 
  41. if ($category->ID > 0) { 
  42. if (!$option['has_subcate']) { 
  43. $w[] = array('=''log_CateID'$category->ID); 
  44. else { 
  45. $arysubcate = array(); 
  46. $arysubcate[] = array('log_CateID'$category->ID); 
  47. foreach ($zbp->categorys[$category->ID]->SubCategorys as $subcate) { 
  48. $arysubcate[] = array('log_CateID'$subcate->ID); 
  49. $w[] = array('array'$arysubcate); 
  50. if (!is_null($auth)) { 
  51. $author = new Member; 
  52. $author = $zbp->GetMemberByID($auth); 
  53. if ($author->ID > 0) { 
  54. $w[] = array('=''log_AuthorID'$author->ID); 
  55. if (!is_null($date)) { 
  56. $datetime = strtotime($date); 
  57. if ($datetime) { 
  58. $datetitle = str_replace(array('%y%''%m%'), array(date('Y'$datetime), date('n'$datetime)), $zbp->lang['msg']['year_month']); 
  59. $w[] = array('BETWEEN''log_PostTime'$datetimestrtotime('+1 month'$datetime)); 
  60. if (!is_null($tags)) { 
  61. $tag = new Tag; 
  62. if (is_array($tags)) { 
  63. $ta = array(); 
  64. foreach ($tags as $t) { 
  65. $ta[] = array('log_Tag''%{' . $t->ID . '}%'); 
  66. $w[] = array('array_like'$ta); 
  67. unset($ta); 
  68. else { 
  69. if (is_int($tags)) { 
  70. $tag = $zbp->GetTagByID($tags); 
  71. else { 
  72. $tag = $zbp->GetTagByAliasOrName($tags); 
  73. if ($tag->ID > 0) { 
  74. $w[] = array('LIKE''log_Tag''%{' . $tag->ID . '}%'); 
  75. if (is_string($search)) { 
  76. $search=trim($search); 
  77. if ($search!=='') { 
  78. $w[] = array('search''log_Content''log_Intro''log_Title'$search); 
  79. if(!emptyempty($order)){ 
  80. if($order=='new'){ 
  81. $order = array('log_PostTime'=>'DESC'); 
  82. if($order=='hot'){ 
  83. $order = array('log_ViewNums'=>'DESC'); 
  84. if($order=='comm'){ 
  85. $order = array('log_CommNums'=>'DESC'); 
  86. if($order=='rand'){ 
  87. $order = array('rand()'=>' '); 
  88. //開源軟件:Vevb.com 
  89. $articles = $zbp->GetArticleList('*'$w$order$count, null, false); 
  90. if ($option['is_related']) { 
  91. foreach ($articles as $k => $a) { 
  92. if ($a->ID == $option['is_related']) 
  93. unset($articles[$k]); 
  94. if (count($articles) == $count){ 
  95. array_pop($articles); 
  96. return $articles

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

熱門文章,代碼如下:

  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篇熱門文章,熱評文章,代碼如下:

  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> 

直接用zblogphp的原生代碼,代碼如下:

  1. <img src="{php}$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/"; 
  2. $content = $article->Content; 
  3. preg_match_all($pattern,$content,$matchContent); 
  4. echo $matchContent[1][0]; 
  5. {/php}" /> 

這些代碼前臺編譯出來的html代碼就是:<img src="圖片地址">,可以加在任意想調用的地方.

PHP版隨機文章的調用方法:

不會寫插件,直接爆方法.

1、打開zb_system\function\c_system_event.php

在743行,$zbp->AddBuildModule('previous');后面添加$zbp->AddBuildModule('sjarticles');

在781行,$zbp->AddBuildModule('previous');后面添加$zbp->AddBuildModule('sjarticles');

在最后后面添加如下代碼:

  1. function BuildModule_sjarticles(){ 
  2.         global $zbp
  3.  
  4.         $articles=$zbp->GetArticleList( 
  5.                 array('*'), 
  6.                 array(array('=','log_Type',0),array('=','log_Status',0)), 
  7.                 array('rand()'=>' '), 
  8.                 array(10), 
  9.                 null 
  10.         ); 
  11.         $s=''
  12.         foreach ($articles as $article) { 
  13.                 $s .='' . $article->Title . ''
  14.         } 
  15.         return $s

2、打開zb_system\function\lib\zblogphp.php

在218行,$this->RegBuildModule('previous','BuildModule_previous');后面添加$this->RegBuildModule('hotarticles','BuildModule_sjarticles');

3、打開數據庫,在zbp_module表,添加新數據,15,熱門文章,sjarticles,,0,divsjarticles,ul,0,system,0

調用方法:在相應地方調用{$modules['sjarticles'].Content}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高雄县| 双城市| 双峰县| 崇仁县| 西宁市| 吴旗县| 民勤县| 聂拉木县| 绥中县| 壤塘县| 大埔区| 定兴县| 龙南县| 台前县| 盐亭县| 金昌市| 乐东| 通州区| 寻甸| 巫山县| 洪洞县| 陈巴尔虎旗| 商河县| 景宁| 宁德市| 民乐县| 平安县| 女性| 和龙市| 同仁县| 华宁县| 民和| 万州区| 綦江县| 建平县| 定安县| 视频| 昭平县| 城市| 香港 | 吉安市|