王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

Zblog PHP挪用随机文章、热点文章、热评文章的要领

文章来为列位引见一篇关于ZBLOG PHP挪用随机文章、热点文章、热评文章的例子,愿望这篇教程能够为人人带来协助。

使用方法: 
第一、在我们的主题目录中须要建立include.php文件,如果有就直接增加剧本

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码以下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy4423')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy4423>/*** 猎取文章列表* @param int $count 数目* @param null $cate 分类ID* @param null $auth 用户ID* @param null $date 日期* @param null $tags 标签* @param null $search 搜刮关键词* @param null $order 排序* @param null $option* @return array|mixed*/function TcgetList($count = 10, $cate = null, $auth = null, $date = null, $tags = null, $search = null, $option = null,$order=null) {global $zbp;if (!is_array($option)) {$option = array();}if (!isset($option['only_ontop']))$option['only_ontop'] = false;if (!isset($option['only_not_ontop']))$option['only_not_ontop'] = false;if (!isset($option['has_subcate']))$option['has_subcate'] = false;if (!isset($option['is_related']))$option['is_related'] = false;if ($option['is_related']) {$at = $zbp->GetPostByID($option['is_related']);$tags = $at->Tags;if (!$tags)return array();$count = $count 1;}if ($option['only_ontop'] == true) {$w[] = array('=', 'log_IsTop', 0);} elseif ($option['only_not_ontop'] == true) {$w[] = array('=', 'log_IsTop', 1);}$w = array();$w[] = array('=', 'log_Status', 0);$articles = array();if (!is_null($cate)) {$category = new Category;$category = $zbp->GetCategoryByID($cate);if ($category->ID > 0) {if (!$option['has_subcate']) {$w[] = array('=', 'log_CateID', $category->ID);} else {$arysubcate = array();$arysubcate[] = array('log_CateID', $category->ID);foreach ($zbp->categorys[$category->ID]->SubCategorys as $subcate) {$arysubcate[] = array('log_CateID', $subcate->ID);}$w[] = array('array', $arysubcate);}}}if (!is_null($auth)) {$author = new Member;$author = $zbp->GetMemberByID($auth);if ($author->ID > 0) {$w[] = array('=', 'log_AuthorID', $author->ID);}}if (!is_null($date)) {$datetime = strtotime($date);if ($datetime) {$datetitle = str_replace(array('%y%', '%m%'), array(date('Y', $datetime), date('n', $datetime)), $zbp->lang['msg']['year_month']);$w[] = array('BETWEEN', 'log_PostTime', $datetime, strtotime(' 1 month', $datetime));}}if (!is_null($tags)) {$tag = new Tag;if (is_array($tags)) {$ta = array();foreach ($tags as $t) {$ta[] = array('log_Tag', '%{' . $t->ID . '}%');}$w[] = array('array_like', $ta);unset($ta);} else {if (is_int($tags)) {$tag = $zbp->GetTagByID($tags);} else {$tag = $zbp->GetTagByAliasOrName($tags);}if ($tag->ID > 0) {$w[] = array('LIKE', 'log_Tag', '%{' . $tag->ID . '}%');}}}if (is_string($search)) {$search=trim($search);if ($search!=='') {$w[] = array('search', 'log_Content', 'log_Intro', 'log_Title', $search);}}if(!empty($order)){if($order=='new'){$order = array('log_PostTime'=>'DESC');}if($order=='hot'){$order = array('log_ViewNums'=>'DESC');}if($order=='comm'){$order = array('log_CommNums'=>'DESC');}if($order=='rand'){$order = array('rand()'=>' ');}}$articles = $zbp->GetArticleList('*', $w, $order, $count, null, false);if ($option['is_related']) {foreach ($articles as $k => $a) {if ($a->ID == $option['is_related'])unset($articles[$k]);}if (count($articles) == $count){array_pop($articles);}}return $articles;}</td></tr></table>


然后就是在我们须要的界面模板中挪用。
A - 随机文章

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码以下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy8287')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy8287>{$array=TcgetList(10,null,null,null,null,null,null,'rand');}<ul id="related">{foreach $array as $related}<li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li>{/foreach}</ul></td></tr></table>

随机10篇文章
B - 热点文章

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码以下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3578')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3578>{$array=TcgetList(10,null,null,null,null,null,null,'hot');}<ul id="related">{foreach $array as $related}<li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li>{/foreach}</ul></td></tr></table>


挪用10篇热点文章
C - 热评文章

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码以下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1467')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1467>{$array=TcgetList(10,null,null,null,null,null,null,'comm';}<ul id="related">{foreach $array as $related}<li><span class="time">{$related.Time('m-d')}</span><span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span></li>{/foreach}</ul></td></tr></table>

挪用10篇热评文章。详细的依据我们实际使用挪用就能够。

相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。