局限于函数参数,在zblog php 1.7版本以前使用GetList函数是无法调用热门、热评或随机文章列表的,调用自定义排序列表通常会使用GetArticleList函数,但在zblog php 1.7版本更新之后,GetList函数增加了where_custom、order_custom等多个重要参数,从而可以轻易地调用热门文章、热评文章或随机文章等列表了。
1.7新版本GetList函数:
语法
| 1 | $result = GetList(array(’count’=>10)) //返回array(Post类型) 或是 空array() |
参数
| 12345678910111213141516171819 | array( ‘count’ => 10, //(可省略) ‘cate’ => 1, //(可省略) ‘auth’ => 2, //(可省略) ‘date’ => ‘2020-1’, //(可省略) ‘tags’ => ‘abc’, //(可省略) ‘search’ => ‘s’, //(可省略) //以下是原$option参数的key键 ‘post_type’ => null, //指定查询Post表的类型 (可省略) ‘post_status’ => null, //指定查询Post表的状态 (可省略) ‘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) |
示例:
热门文章
| 12345678910111213 | $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>’; |
热评文章
| 12345678910111213 | $result = GetList(array(’count’=>10,’post_type’=>’post’,’has_subcate’=>true,’order_custom’ => array(’log_CommNums’ => ‘DESC’)));$list = ‘<ul>’;foreach ($result as $item) { $list .= ‘<li><a href="’.$item->Url.’" title="’.$item->Title.’">’.$item->Title.'</a></li>’;}$list .= ‘</ul>’; |
随机文章
| 123456789101112 | $result = GetList(array(’post_type’=>’post’,’has_subcate’=>true,’random’ => 10));$list = ‘<ul>’;foreach ($result as $item) { $list .= ‘<li><a href="’.$item->Url.’" title="’.$item->Title.’">’.$item->Title.'</a></li>’;}$list .= ‘</ul>’; |
附:
GetArticleList函数调用热门文章的代码
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)