zblogphp使用GetArticleList、GetList函數(shù)調用熱門文章列表
一般我們調用ZBLOG PHP文章的時候會用到最新文章、點擊數(shù)、評論數(shù)文章調用,同時我們還可能 會在一些特定的位置調用本周、本月、本年度的熱門文章。
熱門文章
目錄文件:zb_system/function/lib/zblogphp.php
zbp全局操作類ZBlogPHP中有很多數(shù)據(jù)表操作的默認函數(shù):GetArticleList()、GetPageList()、GetCommentList()、GetMemberList()、GetTagList()、GetCategoryList()、GetModuleList()、GetUploadList()這8個獲取列表的函數(shù)正好對應8個默認數(shù)據(jù)表。當前還有很多其他函數(shù)可以調用
ZBlogphp默認的調用點擊率最高的文章(30天內),是全站文章不分時間段、不能按分類調用。
直接在當前使用的主題模板頁面添加如下代碼:
{php} $stime = time(); $ytime = 30*24*60*60; $ztime = $stime-$ytime; $order = array('log_ViewNums'=>'DESC'); $where = array(array('=','log_Status','0'),array('>','log_PostTime',$ztime)); $array = $zbp->GetArticleList(array('*'),$where,$order,array(10),''); {/php} {foreach $array as $cmslist} <li><a href="{$cmslist.Url}" title="{$cmslist.Title}">{$cmslist.Title}</a></li> {/foreach}
調用include方法
在主題include.php文件中加入下面功能函數(shù):
function article_hot(){ global $zbp,$str; $str = ''; $stime = time(); $ytime = 30*24*60*60; $ztime = $stime-$ytime; $order = array('log_ViewNums'=>'DESC'); $where = array(array('=','log_Status','0'),array('>','log_PostTime',$ztime)); $array = $zbp->GetArticleList(array('*'),$where,$order,array(10),''); foreach ($array as $tag) { $str .= "<a href=\"{$tag->Url}\" title=\"{$tag->Name}\">{$tag->Name}</a>"; } return $str; }
當前使用的主題模板頁面中自行調用
{php}echo article_hot();{/php}
新版zblogphp GetList函數(shù)
在Zblog php 1.7版本以前使用GetList函數(shù)是無法調用熱門、熱評或隨機文章列表的,調用自定義排序列表通常會使用GetArticleList函數(shù),但在zblog php 1.7版本更新之后,GetList函數(shù)增加了where_custom、order_custom等多個重要參數(shù),從而可以輕易地調用熱門文章、熱評文章或隨機文章等列表了。
分類ID:可以分類別調用了
目錄文件:zb_system/function/c_system_function.php
GetList($count = 10, $cate = null, $auth = null, $date = null, $tags = null, $search = null, $option = null)
* @param int $count 數(shù)量 (1.7支持復雜的array參數(shù),$count為array時后面的參數(shù)可以不設)
* @param null $cate 分類ID
* @param null $auth 用戶ID
* @param null $date 日期
* @param null $tags 標簽
* @param null $search 搜索關鍵詞
* @param null $option
示例熱門文章
$result = GetList( array( 'count'=>10, 'post_type'=>'post', 'has_subcate'=>true, 'order_custom' => array('log_ViewNums' => 'DESC') )); $list = '<ul>'; foreach ($result as $item) { $list .= '<li><a href="'.$item->Url.'" title="'.$item->Title.'">'.$item->Title.'</a></li>'; } $list .= '</ul>';
參數(shù)示例
array( 'count' => 10, //(可省略) 'cate' => 1, //(可省略) 'auth' => 2, //(可省略) 'date' => '2020-1', //(可省略) 'TAGs' => 'abc', //(可省略) 'search' => 's', //(可省略) //以下是原$option參數(shù)的key鍵 'post_type' => null, //指定查詢Post表的類型 (可省略) 'post_status' => null, //指定查詢Post表的狀態(tài) (可省略) 'only_ontop' => false, //指定全是置頂 (可省略) 'only_not_ontop' => false, //指定全不是置頂 (可省略) 'has_subcate' => false, //指定包含子孫目錄 (可省略) 'is_related' => false, //指定查詢相關文章 (可省略) 'order_by_metas' => false, //指定按Metas值排序輸出結果 (可省略) 'random' => 5, //指定抽取5篇Post表的記錄 (可省略) 'where_custom' => array(array('=', 'log_Template', '')), //自定義where 'order_custom' => array('log_ViewNums' => 'DESC', 'log_CommNums' => 'ASC'), //自定義order )
到此這篇關于zblogphp使用GetArticleList、GetList函數(shù)調用熱門文章列表的文章就介紹到這了,更多相關zblogphp調用熱門文章列表內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
易優(yōu)eyoucms數(shù)據(jù)表結構和字段說明(數(shù)據(jù)字典)
EyouCms是基于TP5.0框架為核心開發(fā)的免費開源的企業(yè)內容管理系統(tǒng),易優(yōu)基本包含了一個常規(guī)企業(yè)網(wǎng)站需要的一切功能。這篇文章主要介紹了易優(yōu)eyoucms數(shù)據(jù)表結構和字段說明(數(shù)據(jù)字典),需要的朋友可以參考下2023-04-04DownPlus 安全補丁 2008-12-12 附修改方法
DownPlus 安全補丁 2008-12-12 修正內容: 修正query.asp的跨站腳本漏洞.2008-12-12fastAdmin表單驗證validate的錯誤提示信息,如何改變位置?
fastAdmin表單驗證validate的錯誤提示,默認是在右側的n-right,如果放在右側不太好看,想調整到其他位置,該怎么操作呢?2023-08-08