Zblog-php实现热门tag和随机tag代码

Zblog 思享 1333浏览

zblogphp的tag标签功能是对分类的一个有力补充,然而除了系统侧边栏组件可以放出以外,似乎就没有用武之地了,这显得很浪费。今天我们就来分享下zblogphp调用指定数量热门tag和随机tag的方法,先贴上热门tag调用代码:

function Get_hotTags($num){  
        global $zbp,$str;  
        $str = '';  
        $array = $zbp->GetTagList('','',array('tag_Count'=>'DESC'),array($num),'');  
        foreach ($array as $tag) {  
            $str .= "<a href=\"{$tag->Url}\" title=\"{$tag->Name}\">{$tag->Name}</a>";  
        }  
        return $str;  
}  

将以上代码写入主题include.php文件中,然后在模板文件调用代码为:

{Get_hotTags(10)} 

调用10个热门tag

指定数量随机tag调用代码:

function Get_randTags($num){  
        global $zbp,$str;  
        $str = '';  
        $array = $zbp->GetTagList('','',array('rand()'=>' '),array($num),'');  
        foreach ($array as $tag) {  
            $str .= "<a href=\"{$tag->Url}\" title=\"{$tag->Name}\">{$tag->Name}</a>";  
        }  
        return $str;  
}  

将以上代码写入主题include.php文件中,然后在模板文件调用代码为:

{Get_randTags(10)}  

随机调用10个tag

推荐阅读

Function get_magic_quotes_gpc() is deprecated报错解决办法

在 PHP 7.4 及更高版本中, get_magic_quotes_gpc() 函数已被弃用。 This means that code using this function will raise a warning or error.以下是解决......

PHP提示:Warning: count():Parameter must be an array or an object that implements Countable

错误原因:PHP7.2以后,count()函数的参数无效时会抛出warning警告。...

PHP7.4 报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated.

PHP7.4运行项目报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated。只需交换 implode() 函数的两个参数!...