吾爱破解 发表于 2022-6-3 12:42

[Z-Blog]调用指定天数/范围内热门/热评文章

今天来介绍一种使用代码实现的指定天数内的热门文章和热评文章的方法,具体可以实现周排行和月排行及年排行等等功能。具体等待你们去发掘了。zblog代码实现调用指定天数热门文章热评文章指定范围内的文章调用zblog代码实现调用指定天数热门文章热评文章指定范围内的文章调用


把以下代码添加到主题的include.php文件:
<p>function cityed.cn_hot($day){</p><p>global $zbp;</p><p>$hot = '';</p><p>$nowtime = time();</p><p>$settime = $day*24*60*60;</p><p>$gettime = $nowtime-$settime;</p><p>$array = $zbp->GetArticleList(array('*'),array(array('=','log_Status','0'),array('>','log_PostTime',$gettime)),array('log_ViewNums'=>'DESC'),array(10),'');</p><p>foreach ($array as $article) {</p><p>$hot .= '<li><a href="'.$article->Url.'" title="'.$article->Title.'" target="_blank">'.$article->Title.'</a></li>';</p><p>}</p><p>$hot .= '';</p><p>return $hot;</p><p>}</p>
调用最近7天的热门文章:

{cityed.cn_hot('7')}//这里的7就是7天内,如果实现月排行只需要改成30即可,年排行类同。
把这段代码添加需要调用的地方即可。把数字 7 改为自己要调用的天数即可。

调用热评文章代码如下
<p>functioncityed.cn_hotp($day){</p><p>global $zbp;</p><p>$hot = '';</p><p>$nowtime = time();</p><p>$settime = $day*24*60*60;</p><p>$gettime = $nowtime-$settime;</p><p>$array = $zbp->GetArticleList(array('*'),array(array('=','log_Status','0'),array('>','log_PostTime',$gettime)),array('log_CommNums'=>'DESC'),array(10),'');</p><p>foreach ($array as $article) {</p><p>$hot .= '<li><a href="'.$article->Url.'" title="'.$article->Title.'" target="_blank">'.$article->Title.'</a></li>';</p><p>}</p><p>$hot .= '';</p><p>return $hot;</p><p>}</p>
上面这段代码添加到主题的include.php文件,然后把

{ cityed.cn_hotp('7')}//这里的7就是7天内,如果实现月排行只需要改成30即可,年排行类同。
把这段代码添加需要调用的地方即可。

页: [1]
查看完整版本: [Z-Blog]调用指定天数/范围内热门/热评文章